Calling Javascript After Web Method has fired - How?

Calling Javascript After Web Method has fired - How?

Hi all,

I'm trying to implement the cascading dropdown from the asp.net ajaxtoolkit. I need to get the count in a sub category dropdown, if it's zero then I turn off the visibility of the sub category.

If I use the javascript OnChange event then my script fires before the web method, so I need to know how to fire my script AFTER the web method has fired please.

I've been told that I can use jQuery.ajax() method, but Im unsure of the syntax, could anyone help me out please?


My demo page: http://bit.ly/92RYvq

Below is my code and the order I need it to fire.

  1. [WebMethod]
    public CascadingDropDownNameValue[] GetSubCats1(string knownCategoryValues, string category)
    {
       
    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
       
    int CategoryID;
       
    if (!kv.ContainsKey("Category") || !Int32.TryParse(kv["Category"], out CategoryID))
       
    {
           
    return null;
       
    }
        dsSubCat1TableAdapters
    .Categories_Sub1TableAdapter SubCats1Adapter = new dsSubCat1TableAdapters.Categories_Sub1TableAdapter();
        dsSubCat1
    .Categories_Sub1DataTable SubCats1 = SubCats1Adapter.GetSubCats1(CategoryID);

       

    List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
       
    foreach (DataRow dr in SubCats1)
       
    {
            values
    .Add(new CascadingDropDownNameValue((string)dr["SubCategory1"], dr["SubCatID1"].ToString()));
       
    }
       
    return values.ToArray();
    }

    This is the javascript I want to fire after the web method has fired:

  2. function getSubCatCount() { $get("ddlSubCats1").style.display = $get("ddlSubCats1").length > 1 ? "block" : "none"; }
Thanks
Melt