jquery - Incrementally load a webpage -


is possible use ajax , jquery incrementally load webpage using asp.net.

i have webpage, runs 30 queries; each against different databases (my organisation has 30 databases). unfortunately each query takes 7 seconds run (on average). have spent time optimizing queries (they took average of 30 seconds run each).

i webpage to: run query 1 , display output (grid view), run query 2 , display output (grid wiew) of query 1 , two, run query 3 , display output of query one,two , 3 etc. thought using response.flush (see question: response.write , asp.net controls), guffa says not possible when using web controls. how can incrementally load webpage using ajax, jquery etc?

yes possible. queries have executed serially? if not, can run queries in parallel.

every ajax call has option of calling function after successful completion. when each ajax call completes, specify return data formatting , presentation code function subsequent ajax call @ bottom of code.

the following code example generalized jquery ajax database call can used execute number of database calls serially. assumes database has http post api responds json because didn't specify data access methods used databases.

the myfunction parameter specifies function called after database responds. myerrorfunction parameter specifies error handler. myquery parameter specifies api call. myparams parameter list of number of comma delimited parameters supplied http post parameters in url. take format &p0=..&pn=

function apitofunction6(myfunction,myerrorfunction,myquery,myparams) {   var datstr = "";   var indx = 0;   var ajaxhandle;    if (myparams != null) {     (indx = 0; indx < (arguments.length-3); indx++) {       datstr = datstr + "&p" + indx + "=" + encodeuricomponent(arguments[indx+3]);     }   }    ajaxhandle = $.ajax({   type: "post",   url: "aqapi",   data: "howsmyapiq=" + myquery + datstr,   datatype: "json",   trycount: 0,   retrylimit: 3,   complete: function sortdata() {},   success: function(myjson,textstatus,jqxhr) {       myfunction(myjson,textstatus,jqxhr);   },   error: function(jqxhr, textstatus, errorthrown) {       if (textstatus == 'timeout') {         this.trycount++;         if (this.trycount <= this.retrylimit) {           var retryhandle = $.ajax(this);           pendingfunction.push(retryhandle);           return retryhandle;         }       }        if (errorthrown == 'authorization required') {         window.location = "/login";       }       myerrorfunction(jqxhr, textstatus, errorthrown);   }   });   pendingfunction.push(ajaxhandle);    return ajaxhandle; } 

the function can called in sequence this:

arresultindex = apitofunction6(pc_myonget,pc_myonfail,"showincident3",sortorder,count,offset);  function pc_myonget (mydata,myts,myjqxhr,datstr,myparams) {   //format , display data   //...   arresultindex2 = apitofunction6(pc_myonget2,pc_myonfail2,"showincident4",sortorder,count,offset); }  function pc_myonget2 (mydata,myts,myjqxhr,datstr,myparams) {   //format , display data   //...   arresultindex3 = apitofunction6(pc_myonget3,pc_myonfail3,"showincident5",sortorder,count,offset); } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -