PDA

View Full Version : Making right AJAX request to server



neosky
21 Jul 2014, 4:02 AM
Hello i am sending an Ajax request to an endpoint on my server:


Nothing bookSoldOut(boolean sold,
List<Long> books)
throws ErrorResponseException

Where I am expecting the parameters: sold (boolean) and books (array)
In my ExtJS controller I am making a call in a function as follows:


Ext.Ajax.request({
url: '/book/price/bookSoldOut',
method: 'POST',
params: {
'sold': true,
'books': books,
},
success: function(responseObject) {
}});

But I am getting an error code 415 - what I'm doing wrong?

vardhan22
21 Jul 2014, 4:59 AM
By using params the post buffer will be URLencoded like data. if you replace it by jsonData ?then it will post raw JSON. I am hoping, you want raw JSON at your server.

See the thread
http://www.sencha.com/forum/showthread.php?40457-posting-JSON-data-with-ext.ajax.request