Ajax请求无效字符 [英] Ajax request has invalid characters
本文介绍了Ajax请求无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个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
},
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'
},
这篇关于Ajax请求无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文