asp.net mvc - Order the loading of divs (Partial views) with Ajax -


i have page (main view) contains several partial views. loading these partial views specific divs using ajax.

my problem want load these divs in order : first div, second... getting page loads fine order of partial views appearance not right. there way force order of loading partial views ?

since loading them via ajax, need loading of second div callback of ajax loads first div, , loading of third div callback of ajax loads second div. this:

$(document).ready(function() {     $.ajax({         url : '/controller/div1action', // first div url         type: 'get',         success: loadseconddiv     }); });  function loadseconddiv() {     $.ajax({         url : '/controller/div2action', // second div url         type: 'get',         success: loadthirddiv     }); }  function loadthirddiv() {     $.ajax({         url : '/controller/div3action', // third div url         type: 'get'     }); } 

you'll want choose better names functions based on divs are.

update based on comment: you'll want call function rather put down function name if you're wrapping in anonymous function:

$.ajax({     url: '/loadingpartials/loadcontact',     contenttype: 'application/html; charset=utf-8',     type: 'get',     datatype: 'html' }).success(function (result) {     $("#ajaxcontactgrid").html(result);     loadinsurance(); // don't forget parentheses here });  function loadinsurance() {     $.ajax({         url: '/loadingpartials/loadinsurance',         contenttype: 'application/html; charset=utf-8',         type: 'get',         datatype: 'html' }).success(function (result) {             $("#ajaxligrid").html(result);             // call function load 3rd div here (make sure include parentheses call it)     }) } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -