I really dont know why this isnt working!
<script src="js/jquery.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
function updateVA开发者_Python百科L()
{
var f = document.getElementById("nu");
var val=f.value;
alert(val); // it displays the value properly
$.post("getDATA.php", {id: val}); // I sent the variable with jquery
}
</script>
getDATA.php
$value=$_POST['id'];
echo $value;
and when I access getDATA.php to see if it was sent I get this:
Notice: Undefined index: id in C:\Users\dan...
why the variable 'id' isnt set ? why is isnt passed to the server ?
Any help would be appreciated :) Cheers,
dan.
Parameters are being sent via ajax - so this js
script calls getDATA.php
and $_POST['id']
is "seen" there only at that time.
And you are trying to access getDATA.php
after and send no post
or get
parameters by your briwser - so you don't see this params there.
You have to catch echo
by your js
script. Look at this demo:
$.post("test.php", { name: "John", time: "2pm" },
function(data) {
alert("Data Loaded: " + data);
});
精彩评论