Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery ajax不发送请求_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript jquery ajax不发送请求

Javascript jquery ajax不发送请求,javascript,jquery,ajax,Javascript,Jquery,Ajax,我对以下代码有问题 var sendJson = (JSON.stringify(comanda)); $.ajax({ url: 'sendMail.php', type : "post", data: sendJson, success: function(data){ alert("Comanda dumneavoastra a fost trimisa"); } }); 似乎没有发送数据。。。。知道为什么吗 好的。。。我知道没

我对以下代码有问题

var sendJson = (JSON.stringify(comanda));

$.ajax({
    url: 'sendMail.php',
    type : "post",
    data: sendJson,
    success: function(data){
        alert("Comanda dumneavoastra a fost trimisa");
    }
}); 
似乎没有发送数据。。。。知道为什么吗

好的。。。我知道没有发送任何内容,因为我使用firebug监视请求。
我没有收到任何错误,控制台中没有任何内容。如果它被激活了,它就被激活了。

以下是我评论的意思:

var sendJson = (JSON.stringify(comanda));

$.ajax({
    url: '/resource_url_goes_here',
    type : 'POST',
    data: sendJson,
    success: function(data){
        /* implementation goes here */ 
    },
    error: function(jqXHR, textStatus, errorThrown) { 
        /* implementation goes here */ 
    }
}); 
注意,ajax请求现在有一个
错误
回调。所有请求都应该有一个错误回调,这样您就可以很容易地识别错误发生的时间(正如您所看到的,firebug并不能捕获所有内容)

另一件我有时觉得有用的事情是
StatusCodes

$.ajax({
    url: '/resource_url_goes_here',
    type : 'POST',
    data: sendJson,
    statusCode: {  
        404: function() {  
            /*implementation for HTTP Status 404 (Not Found) goes here*/
        },
        401: function() {  
            /*implementation for HTTP Status 401 (Unauthorized) goes here*/
        } 
    },
    success: function(data){
        /* implementation goes here */ 
    },
    error: function(jqXHR, textStatus, errorThrown) { 
        /* implementation goes here */ 
    }
});
当服务器返回一个特定的状态代码(在这个代码段中是404和401)时,这将执行一个函数,并且您可以为您需要的状态代码指定一个特定的处理程序。
你可以找到更多关于这方面的信息。

以下是我评论的意思:

var sendJson = (JSON.stringify(comanda));

$.ajax({
    url: '/resource_url_goes_here',
    type : 'POST',
    data: sendJson,
    success: function(data){
        /* implementation goes here */ 
    },
    error: function(jqXHR, textStatus, errorThrown) { 
        /* implementation goes here */ 
    }
}); 
注意,ajax请求现在有一个
错误
回调。所有请求都应该有一个错误回调,这样您就可以很容易地识别错误发生的时间(正如您所看到的,firebug并不能捕获所有内容)

另一件我有时觉得有用的事情是
StatusCodes

$.ajax({
    url: '/resource_url_goes_here',
    type : 'POST',
    data: sendJson,
    statusCode: {  
        404: function() {  
            /*implementation for HTTP Status 404 (Not Found) goes here*/
        },
        401: function() {  
            /*implementation for HTTP Status 401 (Unauthorized) goes here*/
        } 
    },
    success: function(data){
        /* implementation goes here */ 
    },
    error: function(jqXHR, textStatus, errorThrown) { 
        /* implementation goes here */ 
    }
});
当服务器返回一个特定的状态代码(在这个代码段中是404和401)时,这将执行一个函数,并且您可以为您需要的状态代码指定一个特定的处理程序。
您可以找到有关此的更多信息。

您会遇到哪些错误?添加一个
error
回调,will可以获得有关实际错误的更多信息。这就是问题所在。没有错误。另外,请尝试使用fiddler查看发送了哪些请求。www.fiddlertool.com让我们重新表述这个问题:你看到哪些迹象表明这不起作用。。。添加了回调并发现问题。这是一个糟糕的uri。。。虽然我通常也从fbug得到错误的uri。我需要帮助。。。作为答案发布,以便我可以接受。你有什么错误?添加一个
error
回调,will可以获得有关实际错误的更多信息。这就是问题所在。没有错误。另外,请尝试使用fiddler查看发送了哪些请求。www.fiddlertool.com让我们重新表述这个问题:你看到哪些迹象表明这不起作用。。。添加了回调并发现问题。这是一个糟糕的uri。。。虽然我通常也从fbug得到错误的uri。我需要帮助。。。作为答案张贴,所以我可以接受请。