简体   繁体   English

jQuery Ajax不将发布数据发送到Google Chrome中的php

[英]jquery ajax not sending post data to php in google chrome

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 并且POST数据未在PHP google chrome检验器上接收到,并且状态为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中也可以正常工作

'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来检查是否有成功响应。

Make sure that your PHP returns a valid XML. 确保您的PHP返回有效的XML。 In the Chome Inspector under Network tab. 在“网络”选项卡下的“ Chome检查器”中。 You click on the request for your script "includes/functionsMisc.php", you should see the raw XML output under the Response tab. 单击对脚本“ includes / functionsMisc.php”的请求,您应该在“响应”选项卡下看到原始XML输出。

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有关。

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

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