1

i'm trying to make a test with ajax response using an external array as a config file...

But it isn't working, i'm getting always a blank response...
Can anyone point me the reason?

Here is the link of jsBin test: http://jsbin.com/udanu/2/edit

Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
cusspvz
  • 5,143
  • 7
  • 30
  • 45

2 Answers2

6

It looks like you have bumped into the Same Origin Policy. You cannot make Ajax requests to hosts outside your domain, unless you use JSONP, or some other technique to get around the policy.

You may want to check out the following Stack Overflow post for a few popular solutions to work around the SOP (mainly the JSONP, CORS and Reverse Proxy methods):

Community
  • 1
  • 1
Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
  • @CuSS: I've updated my answer with a link which you may find interesting. – Daniel Vassallo Aug 30 '10 at 10:16
  • i'm trying correcting with: header("Access-Control-Allow-Methods: POST"); AND header("Access-Control-Allow-Origin: *"); but they aren't working – cusspvz Aug 30 '10 at 11:02
  • @CuSS: Maybe you'd want to post a new question on this. I don't have much experience with CORS, but I'm sure others on Stack Overflow do. – Daniel Vassallo Aug 30 '10 at 11:14
2

As you are trying to get data from another domain, maybe you should try using "jsonp" instead of "text" as a dataType.

EDIT: didn't see the previous answer.

PJP
  • 756
  • 3
  • 15