ajax jquery无法正常工作

Poo*_*oja 0 ajax jquery

我编写了下面的代码来使用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){ 为什么我收到此错误?

Mik*_*ran 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();
        }
    }
});
Run Code Online (Sandbox Code Playgroud)