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, you must use global variables in the script. Use global variables to extract XX values.
Jquery retrieves the return value from the $. Ajax event and adds the event CopyCode The 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>