简体   繁体   中英

jquery ajax not sending post data to php in google chrome

I have this ajax call:

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

This works ok on firefox.

I'm using 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

'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.

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.

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.

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