AJAX Request from Phonegap Android fails

前端 未结 3 346
Happy的楠姐
Happy的楠姐 2020-12-02 20:50

I have been working on this for the last two days, and looking at a lot of other suggestions. Yes I can get this simple ajax request to work from within a phonegap applicati

相关标签:
3条回答
  • 2020-12-02 21:19

    additionally to the whitelisting, make sure the cors flag is true to enable cross origin resource sharing.

    $.support.cors=true;
    

    please find the reference here

    0 讨论(0)
  • 2020-12-02 21:25

    You should whitelist the domain in order for your AJAX calls to work.

    Add this line to config file -:

    <access origin="*" />
    

    Phonegap's default policy blocks all network access unless specified otherwise. The above line will disable this security restriction. You can also be more specific in allowing only certain domains to bypass this security feature by including the domain name in the config file like so

    <access origin="http://yourdomain" />
    
    0 讨论(0)
  • 2020-12-02 21:39

    I had a localhost url as I was using Visual Studio. I resolved by editing the VS projects Applicationhost.config file and making a version of the binding protocol so that is it :port: not *:port:localhost, and then accessing via ip address. Make sure to get all references to the port.

    0 讨论(0)
提交回复
热议问题