Php 无法将数据发送到服务器端?

Php 无法将数据发送到服务器端?,php,jquery,ajax,Php,Jquery,Ajax,我有以下代码 $.ajax({ type: "POST", data: { 'id': id }, url: 'http::/localhost/my_project/controller/method', success: function(data) { swal({ title: "Deleted", text: "The list has been deleted.", type: "success" },

我有以下代码

$.ajax({
  type: "POST",
  data: {
    'id': id
  },
  url: 'http::/localhost/my_project/controller/method',
  success: function(data) {
    swal({
      title: "Deleted",
      text: "The list has been deleted.",
      type: "success"
    },
    function(){
      location.reload();
    });
  },
  error: function(data) {
    swal("We cannot delete!", "The file is not deleted.", "error");
  }
});
给定代码,我试图在后台发送数据,但它没有到达控制器的方法

知道这个问题吗?

试试这个

 $.ajax({
            type: "POST",
            url:/* base url */ + "index.php/controller/method",
            data: {id:id },
            success: function(data) {    
        //success
            }
            });

是url中的打字错误吗
http://
应该是
http://
您应该开始使用浏览器开发控制台(通常使用F12打开)。它允许您进行各种调试和检查。例如,它将显示javascript错误和网络请求是否完成。在后端,您使用的是什么?我只是错误地在问题中写入了http::但在我的代码中这是正确的。我使用codeigniter作为后端框架。鉴于上述问题,可以使用GET方法发送数据,但不使用POST。是否需要配置其他设置?
base\u url
不是标准的PHP函数,codeigniter似乎在使用该函数,请更改它。如果你能更好地格式化你的代码也会更好。是的,这基本上是我的代码,但问题仍然存在。我确实解决了问题,我首先尝试了测试,创建了一个简单的ajax工作示例,并在找到解决方案后再次应用到codeigniter,无论如何,谢谢你的帮助。