javascript - How to run ajax script if the page is refreshed -


I want to execute an Ajax script when the page refreshes.

My problem is that this 'work' - AJAX script is not running.

script:

  $ (window) .bind ("load", function () {var data = {}; Data.emailCodeResult = $ ('# emailCodeResult' Val (); $ .ajax ({type: "POST", url: "Oppa / view / viewOther.php", data: data, cache: incorrect, datatype: "JSON", success: work (results) { $ ("# Prof_talent"). Val (result.oth_hobbies); $ ("# prof_recognition"). Val (result.oth_recognition); $ ("# prof_organization") Val $ ("# Prof_workExperience"). $ (" $ ("# Prof_workExperience"). $ ("# Prof_training Programs"). Val (result.oth_training programs); $ ("Show-page [data-page = profile_other_info]"). Trigger ("click")}}} ; Return return;});  

From your comment, it seems that $ ('# emailCodeResult') . Val () is still empty when your AJAX call fire is continuously using setinterval , so to ensure that your data.emailCodeResult Gets the material?

  // Assistant Work (see http://www.sitepoint.com/delay-sleep-pause-wait/) Function sleep (milliseconds) {var start = new date (). GetTime (); For (var i = 0; i & lt; 1e7; i ++) {if ((new date). GetTime () - start) & gt; Milliseconds {break; }}} {SO (2000); } While ($ ('$ emailCodeResult') .val () == 'undefined'); // ajax call here  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -