2012-11-09 80 views
0

我已经写了下面的代码使用jQuery进行Ajax调用:阿贾克斯jQuery的不工作

$.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(); 
     } 
    } 
}); 

我收到错误未捕获的SyntaxError:意外的标识符合成功:函数(响应){ 为什么我得到这个错误?

+3

'$(“#error”)。html(“

注册失败!请重试

“).show();' – undefined

+0

如果您的问题中的初始代码格式与您在IDE中的格式相同,那么您应该考虑学习一些代码格式规则,它会帮助您(和其他人)阅读你自己的代码很多 –

回答

4

你缺少一个逗号:

type : 'POST', 
data : { 
    'mobile' : 'update' 

}, //<---- there should be a comma here 
success : function(response){ 
    if(response == 'success') 
    { 

也有一些报价:

$("#error").html("<p>Registration failed!Please try again.</p>").show(); 
5

因为您在数据的右大括号后缺少逗号。

你的代码应该看起来更像是这样的:

$.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(); 
     } 
    } 
}); 
+0

感谢Mike和@undefined。有两个错误。 – Pooja

0

你缺少一个逗号权在您的“成功”之前:

data : { 
     'mobile' : 'update' 
    },