ajax - obtaining id of an html element using jquery -
I have to get a postcard from a form and send it by AJAX.
Code is given below:
var $ fields = $ ('# myform: input'). SerializeArray (); Var value = {} jQuery.each ($ field, function (i, field) {values [field.name] = field.value}); MyJson = JSON.stringify (value); Now, instead of values [field.name]
I know that the ID of the element to be sent is the key to post data. I have tried value [$ (this) .attr ('id')] = field.value
but, it is not working
You can use the following:
var value = {}; $ ("#mayform: input"). Each (function (i, field) {values [field.id] = field.value;}); Var str = (JSON.stringify (value));
Comments
Post a Comment