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

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -