English 中文(简体)
URL requests adding POST data to querystring
原标题:

I am using ExtJS to send an Ajax request to a PHP page on a server, wanting to send the parameters as POST variables rather than in the querystring.

I have included a random token in the querystring since we were having caching issues on one of our proxy servers.

Ext.Ajax.request({
url:  ajax.php?action=test&randToken=  + generateRandomToken(),
scope: this,
method:  POST ,
success: ajaxSuccess,
failure: ajaxFailure,
params:
{
    param1:  test ,
    param2:  data ,
}});

The code above works when I run it locally (on a Vista box), and checking the traffic using Fiddler everything appears fine.

When running on our Ubuntu staging server (running Zend server) however, all the ajax requests put the POST data into the querystring as well.

I do not even know where to begin looking for what is causing this. Is it a proxy or something on the network, or maybe a setting on the staging server?

问题回答

Try putting all your params into the POST. You shouldn t have any trouble with caching, since POSTs are not supposed to be cached.

Ext.Ajax.request({
  url:  ajax.php ,
  scope: this,
  method:  POST ,
  success: ajaxSuccess,
  failure: ajaxFailure,
  params: {
    action:  test ,
    param1:  test ,
    param2:  data 
  }
});

Also try passing all params on the query string as a GET. If you re worried about security, note that both POSTs and GETs are passed over HTTP and are easily sniffed if traffic is not encrypted with SSL.

Ext.Ajax.request({
  url:  ajax.php?  + 
    Ext.urlEncode({
      action:  test ,
      randToken: generateRandomToken(),
      param1:  test ,
      param2:  data 
    }),
  scope: this,
  method:  GET ,
  success: ajaxSuccess,
  failure: ajaxFailure
});

And finally, try removing that trailing comma from the params hash. Some browsers (IE) have a fit when trailing commas are left in the js.





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签