Hi everyone, i recently tried to get some script off a remote server through ajax. After days of searching and trying, i finally had it working apart from appending the script inside the success function of the ajax call, but the append script works outside of the ajax function with a little hack(set up a delay) I have the code shown below with more explaination. <code> /*****in page header********/ var flashHTML; $.ajax({ url: "crossdomainURL", data: { 'ClientID': '100', 'CatID': '11', 'LessonID': null, 'ClientUserID': null }, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(data, textStatus) { //alert(data); //alert(data.d); //NOTE: i can get the return data here. //alert(JSON.stringify(data)); flashHTML = data.d; //$("#flash").append(flashHTML); //Note: if I uncomment this line here, the html part of the flashHTML // will be shown on the page but the script will not excute. }, error: function(err) { alert("errr"); } });
/*****in page body********/ <body > <form id="form1" runat="server"> <div id="flash"></div> <script language="javascript" type="text/javascript"> setTimeout("showFlash()", 500); // Setup a time delay, because the flashHTML is obtained from an ajax call, it will NOT // be rdy without the delay. function showFlash() { $("#flash").append(flashHTML); // If i append the flashHTML here, the script inside the flashHTML will be excuted. // if i comment this out and put it inside the success function of the ajax call, it doesn't // work. } </script> </form> </body> </code> does anyone know whats the problem is? any help will be appreciated. Thanks. PS: i tried to set the ajax call the async: false, but it doesn't work. I am not sure whether its a bug or what, but set async to false doesn't have any effect on how the ajax function behaved.