1

I have the following restful api ajax call:

   $.ajax({
                    type: "POST",

                    url: "https://website.com/a/login",

                    data: data,

                    dataType: "json"

                })....

where data is:

data["login"]="username";
data["pass"]="1234";

the problem is that this code only works when run from my domain. But when I put this code to run externally, for example from jsfiddle: http://jsfiddle.net/ or from phonegap. This no longer works, and returns me with nothing.

How would I remedy this?

mugetsu
  • 4,228
  • 9
  • 50
  • 79

2 Answers2

1

The issue is because of Cross-domain Ajax calls. Please take a look at following threads for more information:

I hope this helps :-)

Community
  • 1
  • 1
Qorbani
  • 5,825
  • 2
  • 39
  • 47
0

This would work on PhoneGap but you would need to add your domain to whitelist. http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html

msurguy
  • 524
  • 2
  • 8