问题
I developed an HTML5 application. I want to use it on Intel XDK and all works fine with one exception, a Form with a 'POST' action to use a PHP function which saves a chosen image into a application folder. When I try to use it I get the following error:
Cannot POST /http-services/emulator-webserver/ripple/userapp/x/C/Users/XXXXXXXXX/Documents/Proyectos/centerinformaticapp/www/guardarImg.php
How can I make it work? Can anybody give me an example?
回答1:
You have to make Use of Ajax or XHR.
var formData=$('#formId').serialize();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
console.log("success");
}
};
xhttp.open("POST", "http://yoursite.com/abc.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(formData);//your post data
来源:https://stackoverflow.com/questions/39218168/intel-xdk-can%c2%b4t-use-a-post-form-to-use-a-php-function