(Intel XDK) can´t use a 'Post' form to use a PHP function

一笑奈何 提交于 2019-12-12 02:25:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!