I found something strange in my code, I solved it by selecting element with $('form') however there could be one or more forms on my page to avoid globally selecting, I just want to select a specific form element.
My problem is starts with serialize(), selecting my specific form by using ID selector works but I cant serialize while .submit event. But if I select form with ID ($("#formid")) serialize() not works on form submit.
my JS code is :
var entrylist = $('form'); //<< if I put $("#entrylist) here, 'data' displays null.
entrylist.submit(function(e){
e.preventDefault();
var data = JSON.stringify($(this).serializeObject())
console.log(data);
});
and form is :
<form id="entrylist" action="" method="post">
<textarea name="inputarea"></textarea>
some more inputs.. bla bla
</form>
The result with $('form')
{"inputarea":"brobrobrobro","thread_id":"399196","csrf_token":"aIw3dXzCbJGp4c32PzPeo9pVDKwTkCuQotyRWVll"}
The result with $('#entrylist')
{}
Note: serializeObject is a custom function that I get it from https://stackoverflow.com/a/1186309/1932414