jquery - How do I submit from values using AJAX in such a way that what is passed to the Servlet is a JSON string? -


so function:

function buttonclicked() { $("#mybutton").click(function() {     var field1 = $("#textinput1").val();     var field2 = $("#textinput2").val();     $.ajax({         url:"servvvvlet",         method: "post",         data: { // values forms in data string          },         success: function() {             // success code         },     }); }); 

}

how submit form values in such way submitted json string?

by "json string", string json in it?

function buttonclicked() {     $("#mybutton").click(function() {         var field1 = $("#textinput1").val();         var field2 = $("#textinput2").val();         $.ajax({             url:"servvvvlet",             method: "post",             data: json.stringify({foo: 'bar'}),  // {"foo":"bar"}             success: function() {                 // success code             },         });     }); } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -