0

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

エラーUncaught SyntaxError: Unexpected identifier in line success : function(response){が表示され ます なぜこのエラーが表示されるのですか?

4

3 に答える 3

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();
        }
    }
});
于 2012-11-09T17:28:36.303 に答える
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();
于 2012-11-09T17:30:02.337 に答える
0

「成功」の直前にコンマがありません:

    data : { 
        'mobile' : 'update'
    },
于 2012-11-09T17:30:36.453 に答える