0

I am using the following code to make a ajax request, in Cordova app

        $.ajax(rssUrl, {ct: id, crossDomain: true}).done(
                function (data, textStatus, jqXHR) {
                    var object = $(this);           //extracting context

                    var cntxt = object[0].ct;

                    rssReader.parse(data, textStatus, jqXHR, true, cntxt)
                }
            )
            .fail(alErr);

This request is working fine in the ripple emulators,but doing a build on Physical android device I keep getting the alErr output (the status and readyState of jqXHR object is 0)

Specfically this is not working for http://www.footballnewsguru.com/feeds/posts/default/-/Liverpool?alt=json&max-results=10 It works for other feeds i am accessing

The first answer from jQuery Ajax - Status Code 0? does not seem to be for my app, as the CSP is allowing the request in emulators, there is no DNS problem.

I have been searching for a solution for hours, but mostly they are about the browser refreshing or form submitting before ajax request is sent, but neither are applicable to my case.

[EDIT]

<meta http-equiv="Content-Security-Policy" content="default-src 'self' * data: gap: https://ssl.gstatic.com 'unsafe-inline' 'unsafe-eval'; img-src * data:; style-src 'self' 'unsafe-inline';"> 

here is the meta for CSP. Encoding the URL did not work either.

Community
  • 1
  • 1
TZaman
  • 3
  • 4

1 Answers1

0

Found the answer here: Ajax request failing in cordova/phonegap app on real device

The last answer worked for me by adding

<access origin="http://*" />
<access origin="https://*" />

to config.xml, still wondering why

<access origin="http://www.footballnewsguru.com" />

dose not work.

Community
  • 1
  • 1
TZaman
  • 3
  • 4