jquery - $.ajax callback function is inside another function -


i having 1 function called when ever custom controls loaded. please refer below code.

function load() { getdata(); }  function getdata() {    $. ajax({  url://remote url, type:"get", success:function(data) { //going set data control }  }); } 

so success callback function takes time return "data" (i.e fetch data remote url) load() client side method gets completed , our control rendering. want load() method needs wait until success function return data remote url , load() function completed render our control based on data.

how load() function need wait callback gets completed.

thanks,

siva

1) place client side rendering code inside of success handler...

2) separate method , call success handler.

both approaches solve problem of load function completing , causing ui render before data returns.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -