无法将我的Json帖子发送到我的Web服务

时间:2012-02-04 06:12:50

标签: javascript json web-services

我想将我的Json Post发送到我的网络服务但是我无法理解这个问题,因为我已经将jquery.support.cros = true设置为支持跨域支持可以任何人告诉我我做错了什么...因为我的脚本在WEBAPPLICATION_1上,我的web服务在WEBAPPLICATION_2上,我使用的是jquery 1.7分钟版本

<script type="text/javascript">
jQuery.support.cors = true;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://localhost:13096/GetUpdatedData.asmx/UpdatedData",
data: 'Ip=' + '<%= Request.UserHostAddress%>' + '&location=' + window.location.href + '&Browser=' + BrowserDetect.browser + '&Version=' + BrowserDetect.version + '&Os=' + BrowserDetect.OS,
dataType: 'json',
success: function (msg) { alert(msg.d); },
error: function (XMLHttpRequest, textStatus, errorThrown) { 
alert(errorThrown); } 
});  
</script>

我的网络服务

[System.Web.Services.WebMethod(EnableSession = true)]
public void UpdatedData(string Ip, string location, string Browser, string Version, string Os) 
{
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create   ("http://localhost:13096/Admin.aspx?Ip=" + Ip + "&location=" + location + "&Browser=" + Browser + "&Version=" + Version + "&Os=" + Os);
myReq.Method = "Get";
myReq.BeginGetResponse(ar =>
{
HttpWebRequest req2 = (HttpWebRequest)ar.AsyncState;
var response = (HttpWebResponse)req2.EndGetResponse(ar);
int numVisibleCookies = response.Cookies.Count;
}, myReq);
}

//错误我收到的是内部服务错误我正在使用其他javascript代码来检测浏览器信息所有这些都不是那个问题

0 个答案:

没有答案