Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
Requirement 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 jquery parsed error.
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 implemented it using using jquery with jsonp.
 
var baseurl = "http://localhost:50249/WebService.asmx";
$.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);
        }
    });
 
Getting statusText="No Transport".
status=0

Following Error in browser console.
"Origin http://localhost:64048 is not allowed by Access-Control-Allow-Origin. "

 
Note: In IE8 it is working fine.
 
Can anyone please let me know how to access cross domain webservice ?
 
Thanks in Advance.
Posted 25-Mar-13 9:35am
Adi_1.9K
Edited 25-Mar-13 10:24am
v5
Comments
Prasad Khandekar at 25-Mar-13 15:01pm
   
I think I have posted an answer here in this forum to a similar but different question. Add crossDomain: true in ajax call and before making an ajax call set $.supports.cors = true.
 
Regards,
Turbo_23 at 25-Mar-13 15:18pm
   
thanks for your reply i tried it but it works only for IE. In chrome & mozilla i get error & the error is "Origin http://localhost:64048 is not allowed by Access-Control-Allow-Origin. "

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 25 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100