As one of the evaluation system to join a new function "questionnaire", I would like to use other people do a good survey questionnaire, with others have a good thing is: People do professional, interface beautification and so very user-friendly, but it requires you every time you set up a questionnaire after the release of the Web site, the client access every time is a change of address.
Each time the client clicks on the "questionnaire", it jumps to the appropriate page:
Click "Questionnaire" to enter the questionnaire page:
I use a tab, each time the administrator submits a "questionnaire"
Copy Code code as follows:
<li><a href= "" onclick= "Meizz (This)" > Questionnaire </a></li>
Click "Questionnaires" to call the Meizz function, which returns the "questionnaire" URL to be accessed via Ajax calls:
Copy Code code as follows:
<script type= "Text/javascript" language= "JavaScript" >
function Meizz (e) {
$.ajax ({
Async:false,//Set AJAX synchronization
Type: "Get",//get way
URL: ".. /handler/queryquestionnaire.ashx ",
Returns the data successfully, resolves the returned JSON data and displays it in the Course Information list
Success:function (Strjson) {
Check for data returned in the background
var DataArray = eval (Strjson);
E.href = dataarray[0]. questionnaire;//the URL to visit
},
Failed to return data, pop-up error display
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
alert (Xmlhttprequest.responsetext);
}
});
}
</script>
The phenomenon is e.href if placed on the function of the $.ajax can run, but put in the Ajax inside the binding dynamic return of the address, it can not run. After a depression, finally found the answer: because the AJAX default invocation is asynchronous, so the call processing callback function is not equal to the Ajax invocation of the value of href, the direct initiation of the HREF, where the href is a null value.
Workaround:Change the Ajax invocation method to synchronous, declaring that the Ajax invocation is synchronous:
Copy Code code as follows:
$.ajax ({
Async:false,//Set AJAX synchronization
}
This way, the execution of the href must wait for the AJAX call in the function to complete before triggering, and the desired result is obtained.