Same Origin issue with web service call
        Posted  
        
            by 
                Wjdavis5
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Wjdavis5
        
        
        
        Published on 2013-06-30T21:11:24Z
        Indexed on 
            2013/06/30
            22:21 UTC
        
        
        Read the original article
        Hit count: 238
        
My web server runs at http://mypc.com:80 
`
Given the following snip:
$(window).load(function () {
    var myURL = "http://mypc.com:8000/PSOCharts/service/HighChart_ColumnChart/i";
    $.getJSON(myURL)
        .done(function(data) {alert(data);});
    });
I am running to this error:
XMLHttpRequest cannot load http://mypc.com:8000/PSOCharts/service/HighChart_ColumnChart/i. Origin http://mypc.com is not allowed by Access-Control-Allow-Origin.
I understand why (I think) b/c my webservice runs at port 8000 which is different from what IIS is running on (port 80).
I thought I could get around by using jsonp (according to the jQuery documentation here
So I copied the example of making a call to the flickr api, but it isnt working. Any thoughts/sugggestions?
UPDATE
Ok so my request is being made now:
var myURL = "http://192.168.1.104:8000/PSOCharts/service/HighChart_ColumnChart/i?jsoncallback=?";
    $.ajax({
        url :myURL,
        dataType: "jsonp",
        success: function(data) {a(data)} ,
        error: function(){alert("err");},
        });
But I am continually hitting the error function, here is what's being returned:
[1.4,54.43,49.39,93.23]
Now I'm assuming this is b/c the response text doesnt contain any type of callback
here is the part of the interface I'm calling:
 [WebInvoke(Method = "GET",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "HighChart_ColumnChart/{id}?callback={cb}")]
    List<double> HighChart_ColumnChart(string id,string cb);
Here is the actual function being called:
  public List<double> HighChart_ColumnChart(string id,string cb)
    {
        var z = new List<double>();
        z.Add(1.4);
        z.Add(54.43);
        z.Add(49.39);
        z.Add(93.23);
        return z;
    }
when I debug, the CB param is something like : "jQuery19108121746340766549_1372630643878". How do I modify the code to wrap it correctly? Thanks for the help thus far!
© Stack Overflow or respective owner