Ajax请求无效字符字符、Ajax

由网友(划伤了心_ジ)分享简介:我创建了一个Ajax请求。在新的浏览器能正常工作,但IE7告诉我,有一个与该行,其中函数字符的错误:gettestvaraibles表示。谁能告诉我在哪里,错误可能是什么?$。阿贾克斯('HTTP:// testurl /电子ID = testid',{数据: {功能:gettestvaraibles,game_id:...

我创建了一个Ajax请求。在新的浏览器能正常工作,但IE7告诉我,有一个与该行,其中函数字符的错误:gettestvaraibles表示。谁能告诉我在哪里,错误可能是什么?

  $。阿贾克斯('HTTP:// testurl /电子ID = testid',{
    数据: {
        功能:gettestvaraibles,
        game_id:'630',
        game_score:'50'
    },
    类型:'后',
    数据类型:JSON,
    错误:函数(jqXHR,textStatus,errorThrown){
        执行console.log(jqXHR);
        警报(errorThrown.message);
    },
    成功:函数(){
    }
});
 

解决方案

功能是保留关键字。您需要要么改变它,或者把它包在引号:

 数据:{
    功能:gettestvaraibles,
    game_id:630,
    game_score:50
},
 

AJAX请求

I created an AJAX request. In the new browsers it works fine, but IE7 tells me there is an error with characters in the line, where function: 'gettestvaraibles' stands. Can someone tell me where the error could be?

$.ajax('http://testurl/?eID=testid', {
    data: {
        function: 'gettestvaraibles',
        game_id: '630',
        game_score: '50'
    },
    type: 'post',
    dataType: 'json',
    error: function(jqXHR, textStatus, errorThrown) {
        console.log(jqXHR);
        alert(errorThrown.message);
    },
    success: function() {
    }
});

解决方案

Function is a reserved keyword. You need to either change it, or wrap it in quotes:

data: {
    "function": 'gettestvaraibles',
    "game_id": '630',
    "game_score": '50'
},

阅读全文

相关推荐

最新文章