我试图让AJAX调用,这是我第一次使用AJAX,我的代码如下:AJAX GET请求不工作
$.get("validate.php", { 'userinput':'x'}, function(response) {
if(response.status) alert("Matches found");
else alert("No matches");
});
vaidate.php:
<?php
$user_input=$_GET['userinput'];
//print_r($user_input);
if(!is_null($user_input)) exit('{ "status": true }');
else exit('{ "status": false }');
?>
如果我访问我的validate.php,我得到“未定义索引”错误。什么是正确的方法来做到这一点?
好,一,'的print_r($ USER_INPUT);'需要的jQuery被注释掉正确解析回报,但首先需要解决未定义指数误差 – 2013-05-09 18:09:49
语法是有点过 - 你不需要最后的'}' – karthikr 2013-05-09 18:10:54
是的,它在代码中被评论了,对不起。那是只有当我测试出来 – 2013-05-09 18:11:34