Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string clientscrpt = "javascript:loadclientdet();";
           clientscrpt+="loadCi('" + dt.Rows[0]["ciid"].ToString() + "');";
           clientscrpt+="loadTeam('"+assignedTeamId +"');";
           clientscrpt+="loadEmpName('drpicassignedgroup','drpicassigneename','"+dt.Rows[0]["assigned_empid"].ToString() +"');";
           clientscrpt+="loadEmpdet('drpicassigneename','txticassigneemail','txticassigneedepartment','txticassigneemobile','txticassigneedesignation');";
           clientscrpt+="loadEmpName('drpiccoordinatorgroup','drpiccoordinatorname','"+dt.Rows[0]["coordinator_empid"].ToString() +"');";
           clientscrpt+="loadEmpdet('drpiccoordinatorname','txticcoordinatoremail','txticcoordinatordepartment','txticcoordinatormobile','txticcoordinatordesignation');";

           ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", clientscrpt, true);



I want to fire the functions orderly.For example,loadci() function is to load details of items.
C#
//-------json call function--------------------------//
function loadCi(ciidselect) {
    try {
        var catid = $("#drpiccategory").val();
        var envid = $("#drpicenvironment").val();
        var rest = $('#drpAffectedCI');
        $("#hiddenAffectedCiValue").val('');
       
        $.ajax({
            type: "POST",
            url: "incidentnewform.aspx/loadCIFiltered",
            data: JSON.stringify({ catid: catid, envid: envid }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            beforeSend: function () {
                rest.append("<option>Loading...</option>");
            },
            success: function (data) {
                rest.empty();

                $.each(data.d, function (index, item) {

                    rest.append("<option value='" + item.split('~')[0] + "'>" + item.split('~')[1] + "</option>");
                });

                if (ciidselect != "") {
                  
                    $('#drpAffectedCI').val(ciidselect);
                }
            },
            failure: function (response) {
                alert("Some error occurred...");
            }
        });

    }
    catch (e) {
        alert("Error occurred..");
    }
}

When CI is not fully loaded the next function loadTeam() is fired. I want to load the loadtem() after loadci() onsuccess is called i.e. loadci() completed. when the CI is at beforeSend test the function loadTeam() gets fired.

How to do it with registerstartupscript?

I can not fire the functions in the json onsucess itself one by one due to some reason.

C#
loadci()
{
//some json call//
onsuccess:function(data)
{
loadteam();
}
}


I hope I can make understand.
Posted
Updated 23-Dec-14 0:40am
v2

1 solution

I didn't really understand your question and i am confused especially why you are doing this way. Further, try adding async:false to your AJAX calls. This may or may not be solution to the question,but its based on what i understood from your question.

See this : http://stackoverflow.com/questions/1478295/what-does-async-false-do-in-jquery-ajax[^]

Regards..
 
Share this answer
 
v2
Comments
souvikcode 23-Dec-14 8:39am    
Thanks.It works.I think this thing will not create problem if I fire the each function separately,right?
Thanks7872 23-Dec-14 8:51am    
Yes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900