简体   繁体   English

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

[英]cannot post /file.php with ajax request

My request returns a 404 Not Found when I send an AJAX POST request .当我发送AJAX POST request时,我的请求返回404 Not Found I cannot POST /accountf.php .我不能POST /accountf.php This is my code:这是我的代码:

$.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);
  }
});

However when I use get it returns the whole PHP file in response.但是,当我使用get它会返回整个 PHP 文件作为响应。

在此处输入图片说明

i just change the request path to my xammp htdocs folder and paste my php files there now its working我只是将请求路径更改为我的 xammp htdocs 文件夹并将我的 php 文件粘贴到那里,现在它可以工作了
as作为

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

thank you guys谢谢你们

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM