jquery ajax没有在谷歌浏览器中将帖子数据发送到php

时间:2022-10-09 11:47:35

I have this ajax call:

我有这个ajax调用:

var data = "action=getCheckoutsXML&start="+start+"&end="+end;

        $.ajax({
            type: "POST",
            url: "includes/functionsMisc.php",
            data: data,
            dataType: 'xml',
            async: false,
            success: addCheckouts
        });

also used with:

也用于:

var data = {
"action" : "getCheckoutsXML",
"start" : start,
"end" : end};

and POST data is not received on PHP google chrome inspector gets me a status 200

并且在PHP上没有收到POST数据谷歌浏览器检查员获得状态200

This works ok on firefox.

这在Firefox上运行正常。

I'm using jquery 1.7.1, chrome 24.0.1297, php 5.3.13.

我使用的是jquery 1.7.1,chrome 24.0.1297,php 5.3.13。

Had the same ajax call (diferent parameters) in other pages and they work ok in chrome also

在其他页面中有相同的ajax调用(不同的参数),它们在chrome中也能正常工作

3 个解决方案

#1


0  

Make sure that your PHP returns a valid XML. In the Chome Inspector under Network tab. You click on the request for your script "includes/functionsMisc.php", you should see the raw XML output under the Response tab.

确保PHP返回有效的XML。在“网络”选项卡下的“Chome”检查器中。单击脚本“includes / functionsMisc.php”的请求,您应该在“响应”选项卡下看到原始XML输出。

#2


0  

'Check your url .. usually it should start with / The correct way to post data is

'检查你的网址..通常它应该以/开始发布数据的正确方式

   $.ajax({
        type: "POST",
        url: "/includes/functionsMisc.php",
        data: { action : "getCheckoutsXML", start : "start", end : "end"},
        dataType: 'xml',
        async: false,
        success: function(data) { alert(data); }
    });

I replace the addCheckouts to check if there is success responde.

我替换addCheckouts以检查是否有成功响应。

#3


0  

Try adding this to your initialization, it worked for me:

尝试将此添加到初始化,它对我有用:

$.ajaxSetup({      
   cache: false,    
   data : null      
 });

Apparently this may have something to do with Chrome using uninitialized variables and suchlike.

显然,这可能与Chrome使用未初始化的变量等有关。

#1


0  

Make sure that your PHP returns a valid XML. In the Chome Inspector under Network tab. You click on the request for your script "includes/functionsMisc.php", you should see the raw XML output under the Response tab.

确保PHP返回有效的XML。在“网络”选项卡下的“Chome”检查器中。单击脚本“includes / functionsMisc.php”的请求,您应该在“响应”选项卡下看到原始XML输出。

#2


0  

'Check your url .. usually it should start with / The correct way to post data is

'检查你的网址..通常它应该以/开始发布数据的正确方式

   $.ajax({
        type: "POST",
        url: "/includes/functionsMisc.php",
        data: { action : "getCheckoutsXML", start : "start", end : "end"},
        dataType: 'xml',
        async: false,
        success: function(data) { alert(data); }
    });

I replace the addCheckouts to check if there is success responde.

我替换addCheckouts以检查是否有成功响应。

#3


0  

Try adding this to your initialization, it worked for me:

尝试将此添加到初始化,它对我有用:

$.ajaxSetup({      
   cache: false,    
   data : null      
 });

Apparently this may have something to do with Chrome using uninitialized variables and suchlike.

显然,这可能与Chrome使用未初始化的变量等有关。