使用jquery跨域Web服务调用,Web服务托管在iis6.0上 [英] Cross domain web service call using jquery, web service is hosted on iis6.0
问题描述
场景是:
a)webservice(假设Webservice.asmx)托管在一台服务器上,假设www.xyz .com
b)在www.xyz.com域上,存在访问此Web服务的javascript文件。
c)在www.test.com上,www的javascript文件.xyz.com包含在html页面中。
d)当我运行www.test.com网站的html页面时,我收到以下错误:
<大> 500内部服务器错误(检查浏览器控制台)。
e)当我在www.xyz.com域的html页面中包含相同的javascript文件时,它的工作原理很好。
f)两个应用程序都在IIS6.0上运行
我使用此代码进行跨域Web服务调用:
$ .support.cors = true;
$ .ajax({
类型:'POST',
crossDomain:true,
dataType:jsonp,
jsonpCallback:'jsonCallback' ,
contentType:application / json; charset = utf-8,
url:baseurl +/ HelloWorld,
data:'{}',
dataType: json,
成功:函数(数据){
alert(data.d);
},
错误:函数(错误){
alert(错误。 statusText);
}
});
我在IIS6.0中添加了这个标题条目: Access-Control-Allow-Origin value =*
当我运行它时,我得到 500内部服务器错误(检入浏览器控制台) 。
任何人都可以告诉我如何解决跨域网络服务访问问题。
先谢谢。
.support.cors = true;
.ajax({
ty pe:'POST',
crossDomain:true,
dataType:jsonp,
jsonpCallback:'jsonCallback',
contentType:application / json; charset = utf-8,
url:baseurl +/ HelloWorld,
data:'{}',
dataType:json,
success:function(data ){
alert(data.d);
},
错误:函数(错误){
alert(err.statusText);
}
});
我在IIS6.0中添加了此标头条目: Access-Control-Allow-Originvalue =*
当我运行它时,我得到 500内部服务器错误(检入浏览器控制台) 。
任何人都可以告诉我如何解决跨域网络服务访问问题。
先谢谢。
我遇到过这个问题,我想访问某个网站上的某个页面,但我得到了类似的错误。事实证明,你不能做一个链接其他网站的ajax调用。浏览器不允许。
我通过在同一服务器中调用页面来解决它,并从该页面我与该HTTP页面建立HTTP连接并回显返回的结果作为输出。它符合我的目的
Hi,
Scenario is:
a) webservice(Suppose Webservice.asmx) is hosted on one server, suppose www.xyz.com
b) On www.xyz.com domain, a javascript file is present who accesses this webservice.
c) On www.test.com , the javascript file of www.xyz.com is included in html page.
d) When i run html page of www.test.com site, i got following error :
" 500 internal server error(Check in browser console)."
e) When i include same javascript file in html page of www.xyz.com domain then it works fine.
f) Both applications are running on IIS6.0
I am using this code for cross domain web service call :
$.support.cors = true;
$.ajax({
type: 'POST',
crossDomain: true,
dataType: "jsonp",
jsonpCallback: 'jsonCallback',
contentType: "application/json; charset=utf-8",
url: baseurl + "/HelloWorld",
data: '{}',
dataType: "json",
success: function(data) {
alert(data.d);
},
error: function(err) {
alert(err.statusText);
}
});
I added this header entry in IIS6.0 : Access-Control-Allow-Origin" value="*"
When I run it, i get 500 internal server error(Check in browser console).
Can anyone please let me know how to solve cross domain webservice access issue.
Thanks in Advance.
.support.cors = true;
.ajax({ type: 'POST', crossDomain: true, dataType: "jsonp", jsonpCallback: 'jsonCallback', contentType: "application/json; charset=utf-8", url: baseurl + "/HelloWorld", data: '{}', dataType: "json", success: function(data) { alert(data.d); }, error: function(err) { alert(err.statusText); } });
I added this header entry in IIS6.0 : Access-Control-Allow-Origin" value="*"
When I run it, i get 500 internal server error(Check in browser console).
Can anyone please let me know how to solve cross domain webservice access issue.
Thanks in Advance.
I have faced that issue, I wanted to access a certain page on certain site but I got that similar error. It turns out that you cannot do a ajax call of link other other site. Browser does not allow.
I solved it by calling a page in the same server and from that page I made an HTTP connection with that HTTP page and echo the returned result as output. It served my purpose
这篇关于使用jquery跨域Web服务调用,Web服务托管在iis6.0上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!