0

Guys,

I want to send a cross domain ajax request(http://dict.qq.com/dict?q=language), but the server only provides JSON(Not JSONP) response, is there anyway to make the request ?

Here's what i've did:

$.ajax({
    url:"http://dict.qq.com/dict?q=language",
    dataType:"jsonp",
    type:'get',
    processData:false,
    crossDomain:true,
    contentType:"application/json",
    success:result
});

function result(data){console.log(data);}

The response is :

Uncaught SyntaxError: Unexpected token : 

Thanks !

WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
  • possible duplicate of [Ways to circumvent the same-origin policy](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy) – Quentin Mar 14 '13 at 14:44

2 Answers2

0

The server also needs to be configured to allow cross domain requests, something like:

  Http.Response.current().accessControl("*", "GET,PUT,POST,DELETE,OPTIONS",false);
Dimitri Kennedy
  • 408
  • 3
  • 8
0

Generally the same origin policy prevents you from doing so. If you have access to the other server you can attempt to change the http headers sent to circumvent this. Here's a tutorial for using CORS (Cross-Origin Resource Sharing) to achieve this.

If you have no control over the remote server perhaps you can try using a server-side proxy such as this one

OpherV
  • 6,787
  • 6
  • 36
  • 55