Why this jquery function not executing?
<input id="Edit" name="Edit" value="Edit Record" type="button" onclick="$.get('fetchvalues.php', function(){myCallBack(ReadCookie('UpdateRecordID'));});" />
The ReadCookie function is of another JQuery script.
I want to pass the cookie value to the .php file.
This how I modified:
<td align="left">
<input id="Edit" name="Edit" value="Edit Record" type="button" onclick="$.get('fetchvalues.php', ReadCookie('UpdateRecordID'), myCallBack);" />
</td>
<script type="text/javascript">
$(document).ready(function(){
$("#edit").click(function(){
$.get('fetchvalues.php', function(){
开发者_JAVA技巧 myCallBack(ReadCookie('UpdateRecordID'));
});
});
});
</script>
In the file: fetchvalues.php, I have written an echo statement to check whether AJAX call reaches there or not. But it is not calling that file. What's wrong?
Can't say from what you have just written.
I Would be interested to see more on: myCallBack, fetchvalues.php and ReadCookie
Certainly, start by making the JavaScript unobtrusive, and moving the click binding to the document ready function.
$(document).ready(function(){
$("#edit").click(function(){
$.get('fetchvalues.php', function(){
myCallBack(ReadCookie('UpdateRecordID'));
});
});
});
Another problem. If you're wanting to pass data, then data is the second parameter on the get function. See the documentation here:
http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype
So, your function might be something like:
$.get('fetchvalues.php', ReadCookie('UpdateRecordID'), myCallBack);
(p.s. check out the following for the click binding: http://docs.jquery.com/Events/click)
精彩评论