javascript - Best Practice for sending multiple variables using ajax -
I'm still relatively new to jquery, so I was thinking that to send php to multiple variables using AJAX What was the best practice? For example, should I send variables to this package:
$ Send Ajax ({data: {input: {x: 1, y: 2}}, ...} or personalized variables such as:
$ Ajax ({data: {x: 1, y: 2}, ...}) Whether any performance benefits or any other kind of use of one on one Are you
Thank you for your time,
This function is the simplest when one There are many fields in the form. Serialize ()
& lt; Html & gt; & Lt; Body & gt; & Lt; form action = "#" id = "formend" method = "post" name = "formend" & gt; & Lt; input name = "val1" id = "val1" & gt; & Lt; Input name = "val2" id = "val2" & gt; & Lt; Input name = "val3" id = "val3" & gt; ...... & lt; / Form & gt; & Lt; A href = "javascript:;" Id = "btn_send" & gt; Send & lt; / A & gt; & Lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ ("#btn_send") .click (function () {$ .ajax ({type: 'POST', url: 'ajax / imajaxfhph.php', data: $ ("# formsend"). Serialize (), / / First Send All Forms: Function () {}, Completed: Function () {}, Success: Function (A) {Warning (A);}})}}; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment