Yasser1984
Yasser1984

Reputation: 2451

How to make POST requests rather than GET requests using proxy model?

I'm using this example in my code, for some reason it sends requests as GET not POST, I don't see that being set anywhere, how do I change it to Post?

http://dev.sencha.com/deploy/ext-4.0.2a/examples/grid/infinite-scroll.html

Thanks

Upvotes: 0

Views: 178

Answers (2)

Bobik Sdoh
Bobik Sdoh

Reputation: 110

Generaly jimbojw is right. However you can use POST by setting proxy config like this:

proxy: {
  type: 'ajax',
  url: 'test.php',
  getMethod: function(request){ return 'POST'; }
  // ...

Upvotes: 2

jimbo
jimbo

Reputation: 11042

Since the data lives in another domain, and is being included via JSONP, GET is the only available option.

In order to POST, you either need to be in the same domain so as not to violate the Same Origin Policy, or use Cross-Origin Resource Sharing.

Having said all that, I don't see anything in the Ext.data.Store documentation that specifically talks about the Proxy's methods, and the Ext.data.DataProxy documentation isn't much help either.

And, Quentin is generally right, you probably want a GET request anyway since this is more semantically appropriate. You may be forced to use POST in some circumstances, for example if the amount of data you plan to send to the server is greater than the allowable GET URL length, but generally this shouldn't be an issue.

Upvotes: 1

Related Questions