Reputation: 44
I have a form for a single field on my page, I just want to know either it is better to send a single parameter like
var myObject = {myParameter:'My Value'};
OR
var myObject = {myParameter : myForm.Serialize()};
Upvotes: 0
Views: 218
Reputation: 70718
It depends on what the service/controller is expecting to receive. If the parameter is a form
use .serialize()
else just specify the value directly.
Behind the scenes .serialize()
creates a text based string based upon the form elements. I.e.:
formItem=FormItem1&FormItem2=formItem2
So it really makes no difference.
Upvotes: 2