Currently, I\'m sending the data via code in this way and it\'s working but how can I send the entire form in json?
Code :
$.ajax({
url : w
You could grab the form data usingserializeArray
function in jQuery, then convert it into dictionary and send as post data.
The serializeArray
function output would be something like,
{
'name': 'the_name',
'value': 'the_value'
}
Then, you would have to convert it to the dictionary or json format. Write a global function for that,
function objectifyForm(formArray) {
var returnArray = {};
for (var i=0;i
Call it whenever you have to grab the form data,
var formData = $('#my_form').serializeArray();
formData = objectifyForm(formData);
$.ajax({
url : window.location.href, // the endpoint,commonly same url
type : "POST", // http method
data : formData,
success: blaah,
error: bleeh,
});
It would be much less effort than having to decode the dictionary every time from the server side.