Cordova: Failed to execute 'send' on 'XMLHttpRequest'












0















I am trying to bring back my Cordova App, since the last time it was working my server expired and I had to rebuild the database and load my php interfaces, on a different domain than it used to be hosted.



So after all the work on the server was done and everything is like it was, I changed all links in my app and the permissions to external sources but still when I run the app, when it encounters the first getJSON call it gives the following error on the javascript console:



Failed to load resource jquery-3.2.1.js (9566,10)



On the output stream it says:



E chromium: [ERROR:sync_resource_handler.cc(63)] Cross origin redirect denied



I added the following error function to get a better idea of the error:



console.log(xhr.status + status + error);


and got this on the console:



0errorNetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www.squirreldevelopment.it/notebet/request_utilities.php'.



I have whitelist plugin installed and the following in my config.xml :



<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<allow-navigation href="https://squirreldevelopment.it/notebet/*" />
<allow-intent href="https://squirreldevelopment.it/notebet/*" />
<access origin="https://squirreldevelopment.it/notebet/*" />


I also tried with href="*" with no success.



In the html head i have



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


At the top of the php file i have:



<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Content-Type: application/json');
header('HTTP/1.1 200 OK');


I checked the generated manifest and there is the permission for internet access



I did try to reinstall the whitelist plugin with no success.



this is my original piece of code that does the call:



        $.getJSON('https://www.squirreldevelopment.it/notebet/request_request_utilities.php', function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
});


This is the code I am using now to debug (they get the same error):



        $.ajax({
crossDomain:true,
dataType: "json",
url: "https://www.squirreldevelopment.it/notebet/request_utilities.php",
success: function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
},
error: function (xhr, status, error) {
console.log(xhr.status + status + error);
}
});


I have no more clues on how to fix this.
Hopefully someone can help.










share|improve this question























  • I forgot to say I set async: false

    – Lucaz97
    Nov 20 '18 at 20:42
















0















I am trying to bring back my Cordova App, since the last time it was working my server expired and I had to rebuild the database and load my php interfaces, on a different domain than it used to be hosted.



So after all the work on the server was done and everything is like it was, I changed all links in my app and the permissions to external sources but still when I run the app, when it encounters the first getJSON call it gives the following error on the javascript console:



Failed to load resource jquery-3.2.1.js (9566,10)



On the output stream it says:



E chromium: [ERROR:sync_resource_handler.cc(63)] Cross origin redirect denied



I added the following error function to get a better idea of the error:



console.log(xhr.status + status + error);


and got this on the console:



0errorNetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www.squirreldevelopment.it/notebet/request_utilities.php'.



I have whitelist plugin installed and the following in my config.xml :



<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<allow-navigation href="https://squirreldevelopment.it/notebet/*" />
<allow-intent href="https://squirreldevelopment.it/notebet/*" />
<access origin="https://squirreldevelopment.it/notebet/*" />


I also tried with href="*" with no success.



In the html head i have



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


At the top of the php file i have:



<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Content-Type: application/json');
header('HTTP/1.1 200 OK');


I checked the generated manifest and there is the permission for internet access



I did try to reinstall the whitelist plugin with no success.



this is my original piece of code that does the call:



        $.getJSON('https://www.squirreldevelopment.it/notebet/request_request_utilities.php', function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
});


This is the code I am using now to debug (they get the same error):



        $.ajax({
crossDomain:true,
dataType: "json",
url: "https://www.squirreldevelopment.it/notebet/request_utilities.php",
success: function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
},
error: function (xhr, status, error) {
console.log(xhr.status + status + error);
}
});


I have no more clues on how to fix this.
Hopefully someone can help.










share|improve this question























  • I forgot to say I set async: false

    – Lucaz97
    Nov 20 '18 at 20:42














0












0








0








I am trying to bring back my Cordova App, since the last time it was working my server expired and I had to rebuild the database and load my php interfaces, on a different domain than it used to be hosted.



So after all the work on the server was done and everything is like it was, I changed all links in my app and the permissions to external sources but still when I run the app, when it encounters the first getJSON call it gives the following error on the javascript console:



Failed to load resource jquery-3.2.1.js (9566,10)



On the output stream it says:



E chromium: [ERROR:sync_resource_handler.cc(63)] Cross origin redirect denied



I added the following error function to get a better idea of the error:



console.log(xhr.status + status + error);


and got this on the console:



0errorNetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www.squirreldevelopment.it/notebet/request_utilities.php'.



I have whitelist plugin installed and the following in my config.xml :



<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<allow-navigation href="https://squirreldevelopment.it/notebet/*" />
<allow-intent href="https://squirreldevelopment.it/notebet/*" />
<access origin="https://squirreldevelopment.it/notebet/*" />


I also tried with href="*" with no success.



In the html head i have



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


At the top of the php file i have:



<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Content-Type: application/json');
header('HTTP/1.1 200 OK');


I checked the generated manifest and there is the permission for internet access



I did try to reinstall the whitelist plugin with no success.



this is my original piece of code that does the call:



        $.getJSON('https://www.squirreldevelopment.it/notebet/request_request_utilities.php', function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
});


This is the code I am using now to debug (they get the same error):



        $.ajax({
crossDomain:true,
dataType: "json",
url: "https://www.squirreldevelopment.it/notebet/request_utilities.php",
success: function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
},
error: function (xhr, status, error) {
console.log(xhr.status + status + error);
}
});


I have no more clues on how to fix this.
Hopefully someone can help.










share|improve this question














I am trying to bring back my Cordova App, since the last time it was working my server expired and I had to rebuild the database and load my php interfaces, on a different domain than it used to be hosted.



So after all the work on the server was done and everything is like it was, I changed all links in my app and the permissions to external sources but still when I run the app, when it encounters the first getJSON call it gives the following error on the javascript console:



Failed to load resource jquery-3.2.1.js (9566,10)



On the output stream it says:



E chromium: [ERROR:sync_resource_handler.cc(63)] Cross origin redirect denied



I added the following error function to get a better idea of the error:



console.log(xhr.status + status + error);


and got this on the console:



0errorNetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www.squirreldevelopment.it/notebet/request_utilities.php'.



I have whitelist plugin installed and the following in my config.xml :



<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<allow-navigation href="https://squirreldevelopment.it/notebet/*" />
<allow-intent href="https://squirreldevelopment.it/notebet/*" />
<access origin="https://squirreldevelopment.it/notebet/*" />


I also tried with href="*" with no success.



In the html head i have



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


At the top of the php file i have:



<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Content-Type: application/json');
header('HTTP/1.1 200 OK');


I checked the generated manifest and there is the permission for internet access



I did try to reinstall the whitelist plugin with no success.



this is my original piece of code that does the call:



        $.getJSON('https://www.squirreldevelopment.it/notebet/request_request_utilities.php', function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
});


This is the code I am using now to debug (they get the same error):



        $.ajax({
crossDomain:true,
dataType: "json",
url: "https://www.squirreldevelopment.it/notebet/request_utilities.php",
success: function (result) {
console.log("success");
$.each(result, function (i, field) {
console.log("reading request_utilities.php");
status = field.status;
val_aggiorna = field.aggiorna;
console.log("ended reading request_utilities.php");
statusResult = result;
});
if (status == 0) {
errore('Error loading data');
} else {
console.log("status ok");
console.log("requestData");
requestData(urls);
}
},
error: function (xhr, status, error) {
console.log(xhr.status + status + error);
}
});


I have no more clues on how to fix this.
Hopefully someone can help.







ajax cordova cross-domain getjson whitelist






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 20:39









Lucaz97Lucaz97

112




112













  • I forgot to say I set async: false

    – Lucaz97
    Nov 20 '18 at 20:42



















  • I forgot to say I set async: false

    – Lucaz97
    Nov 20 '18 at 20:42

















I forgot to say I set async: false

– Lucaz97
Nov 20 '18 at 20:42





I forgot to say I set async: false

– Lucaz97
Nov 20 '18 at 20:42












1 Answer
1






active

oldest

votes


















0














Please try the CSP like:



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


I would start with config.xml setup like:



 <access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-navigation href="*"/>


If you make it work narrow access according to your need.






share|improve this answer


























  • Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

    – Lucaz97
    Nov 21 '18 at 21:16











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401160%2fcordova-failed-to-execute-send-on-xmlhttprequest%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Please try the CSP like:



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


I would start with config.xml setup like:



 <access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-navigation href="*"/>


If you make it work narrow access according to your need.






share|improve this answer


























  • Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

    – Lucaz97
    Nov 21 '18 at 21:16
















0














Please try the CSP like:



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


I would start with config.xml setup like:



 <access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-navigation href="*"/>


If you make it work narrow access according to your need.






share|improve this answer


























  • Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

    – Lucaz97
    Nov 21 '18 at 21:16














0












0








0







Please try the CSP like:



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


I would start with config.xml setup like:



 <access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-navigation href="*"/>


If you make it work narrow access according to your need.






share|improve this answer















Please try the CSP like:



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


I would start with config.xml setup like:



 <access allows-arbitrary-loads-for-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-navigation href="*"/>


If you make it work narrow access according to your need.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 23:49

























answered Nov 20 '18 at 23:37









markofmarkof

115




115













  • Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

    – Lucaz97
    Nov 21 '18 at 21:16



















  • Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

    – Lucaz97
    Nov 21 '18 at 21:16

















Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

– Lucaz97
Nov 21 '18 at 21:16





Unfortunately it didn't work . The fact that it worked before I migrated to a new server makes me think there could be something I forgot to check/fix but I've googled for everything related to problems with cross requests and I've found nothing I haven't tried

– Lucaz97
Nov 21 '18 at 21:16


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401160%2fcordova-failed-to-execute-send-on-xmlhttprequest%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy