简体   繁体   中英

cannot post /file.php with ajax request

My request returns a 404 Not Found when I send an AJAX POST request . I cannot 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.

在此处输入图片说明

i just change the request path to my xammp htdocs folder and paste my php files there now its working
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 端口

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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