Using $_POST and $_GET properly in PHP

时间:2015-09-14 16:08:40

标签: javascript php jquery post

in a Javscript file, I have code that calls an XML file and I call to it in a php file.

//Javascript
xmlDoc = loadXMLDoc("foo.xml");
var k += xmlDoc.getElementsByTagName("tags")[0].innerHTML;

xmlDoc2 = loadXMLDoc("foo2.xml");
p = xmlDoc2.getElementsByTagName("tag2")[0].innerHTML;

console.log(k);
console.log(p);
$(document).ready(function(){
       $('#call').attr('value', k);
       $('#place').attr('value', p);

//PHP
$calls = $_POST['calls'];
$place = $_POST['place'];

When I console.log k & p, they both show up. When I execute the php and echo it onto the page, k goes through but p does not. It is my understanding that $_POST operates by collecting data that isn't in the URL (which is what $_GET can be used for). I can't wrap my head around why $_POST is working for k and not p. I don't get any errors in the console. I'm loading both xmldocs in the same js, but as I already mentioned, console.log works for both variables.

0 个答案:

没有答案