Internet Explorer问题 - 参数的Web服务调用缺失值无效 [英] Internet Explorer Issue - Invalid web service call missing value for parameter
问题描述
我有一个网络方法:
I have a webmethod:
<WebMethod(Description:="getProductDescription",)> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function getProductDescription(ByVal sellReqID As Integer) As Object
End Function
我正在使用的是:
Which I am calling using:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Haggler.asmx/getProductDescription",
dataType: 'json',
async: false,
data: '{sellReqID:"' + getQueryVariable("sellReqID") + '"}', // Page parameter to make sure we load new data
success: function (data) {
//do something on success here
},
error: function (result) {
alert(JSON.stringify(result));
return flag;
}
});
我从查询字符串中获取sellReqID的值javascript函数如下:
I am getting the value of the "sellReqID" from the querystring using a javascript function as follows:
// get value of querystring
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}
现在奇怪的是,这在所有浏览器中工作正常除了IE 说
无效的网络服务电话,参数缺失值\\\\'sellReqID \\\\ 0000
当我尝试在 Internet Explorer 上运行它时。
请帮我弄清楚实际原因对于这个问题,并指出我的解决方案。任何帮助表示赞赏。
您也可以访问此处的实时链接: http://www.leorbis.com/ProductDescription.aspx?sellReqID=1 [ ^ ]
IE中错误的屏幕截图: http://i.stack.imgur.com/O3EaU.jpg [ ^ ]
更新:如果我删除来自AJAX调用的参数它开始在IE上工作。
Now strangely, this is working fine in all the browsers except IE while it says
Invalid web service call, missing value for parameter \\u0027sellReqID\\u0027
when i try to run it on Internet Explorer.
Please help me figure out the actual reason for the issue and point me towards a solution. Any help is appreciated.
You can also visit the live link here: http://www.leorbis.com/ProductDescription.aspx?sellReqID=1[^]
Screenshot of the error in IE: http://i.stack.imgur.com/O3EaU.jpg[^]
UPDATE: If i remove the Parameter from the AJAX call it starts working on IE.
推荐答案
.ajax({
type: POST,
contentType: application / json; charset = utf-8,
url: Haggler.asmx / getProductDescription,
dataType:' json',
async: false ,
data:' {sellReqID:' + getQueryVariable( sellReqID)+ ' } , // 页面参数,以确保我们加载新数据
成功:功能(数据){
// 在这里取得成功
},
错误: function (结果){
alert( JSON .stringify(result));
返回标志;
}
});
.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Haggler.asmx/getProductDescription", dataType: 'json', async: false, data: '{sellReqID:"' + getQueryVariable("sellReqID") + '"}', // Page parameter to make sure we load new data success: function (data) { //do something on success here }, error: function (result) { alert(JSON.stringify(result)); return flag; } });
我从查询字符串中获取sellReqID的值javascript函数如下:
I am getting the value of the "sellReqID" from the querystring using a javascript function as follows:
// get value of querystring
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}
现在奇怪的是,这在所有浏览器中工作正常除了IE 说
无效的网络服务电话,参数缺失值\\\\'sellReqID \\\\ 0000
当我尝试在 Internet Explorer 上运行它时。
请帮我弄清楚实际原因对于这个问题,并指出我的解决方案。任何帮助表示赞赏。
您也可以访问此处的实时链接: http://www.leorbis.com/ProductDescription.aspx?sellReqID=1 [ ^ ]
IE中错误的屏幕截图: http://i.stack.imgur.com/O3EaU.jpg [ ^ ]
更新:如果我删除来自AJAX调用的参数它开始在IE上工作。
Now strangely, this is working fine in all the browsers except IE while it says
Invalid web service call, missing value for parameter \\u0027sellReqID\\u0027
when i try to run it on Internet Explorer.
Please help me figure out the actual reason for the issue and point me towards a solution. Any help is appreciated.
You can also visit the live link here: http://www.leorbis.com/ProductDescription.aspx?sellReqID=1[^]
Screenshot of the error in IE: http://i.stack.imgur.com/O3EaU.jpg[^]
UPDATE: If i remove the Parameter from the AJAX call it starts working on IE.
如果服务期望一个诸如整数的原语,你不必将值包装在''''中,可能只是一个脑屁。至于获取值,我会创建一个var和parseInt它。您应该首先提醒数据值并在JSON验证器上运行它,我可能会得到逗号错误。
If the service is expecting a primitive such as integer, you don''t have to wrap the value in '''', probably just a brain fart. As far as getting the value goes, I would create a var and parseInt it. You should alert the data value and run it on a JSON validator first, I may of gotten the comma''s wrong.
data: ''{sellReqID:"'' + getQueryVariable("sellReqID") + ''"}'',
var sellReqID = parseInt(getQueryVariable("sellReqID"));
alert("{\""sellReqID:\""" + sellRegID + "}");
data: "{\""sellReqID:\""" + sellRegID + "}";
Json
http://www.json.org/ [ JSON Specs ^ ]
http://jsonlint.com/ [验证器^ ]
这篇关于Internet Explorer问题 - 参数的Web服务调用缺失值无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!