无法使用ajax请求发布/file.php

时间:2018-01-19 10:32:49

标签: php jquery ajax phonegap

当我发送AJAX post请求时,我的请求返回404 Not Found。我不能POST /accountf.php。这是我的代码:

$.ajax({
  url: 'accountf.php',
  data: {
    "getclient": true
  },
  type: 'post',
  success: function(output) {
    alert(output);
  },
  error: function(xhr) {
    alert("An error occured: " + xhr.status + " " + xhr.statusText);
  }
});

但是当我使用get时,它会返回整个PHP文件作为响应。

enter image description here

2 个答案:

答案 0 :(得分:0)

我只是将请求路径更改为我的xammp htdocs文件夹 并粘贴我的PHP文件现在它的工作

$.post('http://localhost/bizmanager/backend/accountf.php',
        { "getclient": true },
        function(data,status){
            alert("Data: " + data + "\nStatus: " + status);
        });
谢谢你们

答案 1 :(得分:-1)

您是否尝试从角度javascript发布到PHP,请确保您的apache / iis正在运行,我认为地址需要处理:80或类似地它不能是angular / Node.js端口

相关问题