views:

47

answers:

2

in my page i am calling a controller using $.get with some parameters ,

that controller returns me a view page (.aspx), now, i bind that page to a different div every time as this function can be iterated (or called multiple times) these div s are already created and then result is mapped to each div

function getview(Name, Parameters, Target) {
     $.get('Home/Submit',
                    { Name: name,
                      Parameters: Parameters
                    },

       function(result) {

           $("#" + Target).html(result);
           //alert("something");

       });
}

this method is called as:

<div id="{{'_Temp' + Id}}">{{getAction('_AddToFavorite', 'ContentId,'
                                    + Id + ',Version,' + Version + ','li_ContentFavorites_Temp'
                                    + Id)}} </div>

Now what happens here is the html gets bind to respective div but only when that 'alert()' is there otherwise the view page gets bind randomly (ie sometime it does sometimes it doesn't) but for last iteration it does.

*I think * that this is because before the data is actually bind to the respective div the next data(viewpage) comes in.

is there any way to make process stop (or delay) so to bind data properly.

A: 

if you use .ajax you can use more options - one of these is timeout

matpol
can you pls. elaborate more??...
dexter
probably best to look at the jquery documentation rather than me repeat what it says here so here is a link: http://docs.jquery.com/Ajax/jQuery.ajax#options It might not do what you want but it might be helpful
matpol
A: 

I had this problem figured out in more then one way, but the easiest solution is always based on jquery ajaxqueue plugin. It just does ajax "one by one" :)

You could stay with Your way, but it would require a lot of debugging - I think Your problem is related to some variables being less local than You think. If You want to load without queueing - please post more details or a link to an example page

naugtur