1

The code is listed below:

    $.ajax({
     type: "POST",
     url: "http://localhost:3000/rcm/global_config/update",    
     data: {k: 'sdfa', v: 'dsfas'},
     success: function(data, textStatus, XMLHttpRequest){
       alert("数据更新成功");
     },
     error: function(xhr,textStatus, errorThrown){
       alert("数据更新失败,请刷新回滚");
     }
    });

In the server i can not get post parameters, and then i tamper the request sent by ajax, it doesn't send the data params at all. i don't know where i am wrong.

thank you in advance.

ywenbo
  • 3,051
  • 6
  • 31
  • 46
  • can you get the parameters if you send them by GET instead of POST? – regality Jan 25 '11 at 04:16
  • change to get, everything is ok. – ywenbo Jan 25 '11 at 04:19
  • I'm trying to debuging your code above using http://jqueryconsole.com/ and its result fine. Using chrome developer tool in network panel I got a form post request with correct Form Data k:sdfa and v:dsfas. Maybe this is a browser issue. Try using another browser. – Gajahlemu Jan 25 '11 at 04:22
  • Does your server get hit up at all? without the parameters? im thinking this is may be a cross domain issue. – The Scrum Meister Jan 25 '11 at 04:22
  • the server is hit, but not capture the POST parameters. – ywenbo Jan 25 '11 at 04:24
  • @Gajahlemu you're right, under IE i can get parameters, i always use FF to debug, just now i still can not get POST parameters under FF sent to server. is there a way to fix under FF – ywenbo Jan 25 '11 at 04:31

4 Answers4

2

This issue has been asked and aswered before in SO jquery-ajax-post-sending-options-as-request-method-in-firefox

This is because the same origin policy on FF. It only allows you to do XMLHTTPRequests to your own domain. Maybe your script is loaded from domain "localhost" and your ajax request to "localhost:3000"

Community
  • 1
  • 1
Gajahlemu
  • 1,253
  • 7
  • 17
0

Please try this

$.ajax({
 type: "POST",
 url: "http://localhost:3000/rcm/global_config/update",    
 data: "{'k': 'sdfa', 'v': 'dsfas'}",       // Change are here in this line
 success: function(data, textStatus, XMLHttpRequest){
   alert("数据更新成功");
 },
 error: function(xhr,textStatus, errorThrown){
   alert("数据更新失败,请刷新回滚");
 }
});
Wazy
  • 8,822
  • 10
  • 53
  • 98
0
   $.ajax({
     type: "POST",
     url: "http://localhost:3000/rcm/global_config/update",    
     data: $.param({k: 'sdfa', v: 'dsfas'}),
     success: function(data, textStatus, XMLHttpRequest){
       alert("数据更新成功");
     },
     error: function(xhr,textStatus, errorThrown){
       alert("数据更新失败,请刷新回滚");
     }
    });

Wrapping the data object in $.param should do it. It will convert that object to the string "k=sdfa&v=dsfas"

gdix
  • 116
  • 4
  • no effect in FF, it's really a browser issue, but i don't know how to make it work under FF. – ywenbo Jan 25 '11 at 04:35
0

hi please try somthing like this:

$.ajax({
        type:"POST",
        url:"student/info/ajax.php",  
        data:({type:'test', r:which}),
        success:function(data){
            if((data.result)=='true')
                $('#result_popup').html(data.output);
            }, 
        dataType:"json"});
        return false;