If you want to get $. the value returned by ajax () cannot be directly used in success: funciton () {return xx}. To obtain the value of xx, use the global variable in the script. Use global variables to extract xx values.
Jquery retrieves the return value from the $. ajax event and adds the event
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> test JQUERY to submit dynamic text </title>
<Script language = "javascript" src = "jquery. js"> </script>
<Script language = "javascript">
$ (Function () {// I will not upload the referenced jquery file. Everyone should have it.
$ ("# A1"). clone (). appendTo ("# ap ");
Var a = ""; // defines global variable;
Txtadd ();
Alert (a); // test whether the global variable has a value;
$ ("# Tall"). blur (function () {alert ("test") ;}); // Add a blur event that returns the text box from the synchronization event
$ ("# A1"). blur (function () {alert ("this page event! ") ;}); // Note that the cloned a1 text box does not have a blur event;
Function txtadd (){
$. Ajax ({
Async: false, // synchronous request, because the asynchronous request cannot pass the return value to the global variable;
Type: "post ",
Url: "autotxt. php ",
Data: {txtid1: 1, txtid2: 2 },
BeforeSend: function () {$ ("# tt" loading .html ("loading data... ")},
Success: function (data) {$ ("# tt" cmd.html (decodeURI (data); // autotxt. php return value <input name = 'tall' id = 'tall' value = 'dc' maxlength = '6'/>;
A = $ ("# tall"). val (); // process the returned value to the global variable.
}
});
}
})
</Script>
</Head>
<Body>
<Form action = "autotxt. php" method = "post">
<Div id = "tt"> </div>
<Div id = "ap"> </div>
<Input type = "text" id = "a1" name = "a1" value = "test"/>
<Input type = "hidden" id = "OK" name = "OK" value = "OK"/>
<Input type = "submit" value = "OK"/>
</Form>
</Body>
</Html>