我编写了下面的代码来使用jquery进行ajax调用:
$.ajax({
url: 'verify.php',
type: 'POST',
data: {
'mobile': 'update'
}
success: function(response) {
if (response == 'success') {
$('#popupscreen').fadeOut('slow');
}
else {
$("#error").html("<p>" + Registration failed! Please try again. + "</p>").show();
}
}
});
Run Code Online (Sandbox Code Playgroud)
我收到错误Uncaught SyntaxError:行成功中的意外标识符:function(response){ 为什么我收到此错误?
因为你在数据的右大括号后错过了一个逗号.
你的代码看起来应该更像这样:
$.ajax({
url: 'verify.php',
type: 'POST',
data: {'mobile': 'update'},
success: function(response) {
if (response == 'success') {
$('#popupscreen').fadeOut('slow');
}
else {
$("#error").html("<p>" + 'Registration failed!Please try again.' + "</p>").show();
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
107 次 |
| 最近记录: |