1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Jquery Dependent Dropdown to load on document ready Help

Discussion in 'jQuery' started by hallianonline, Nov 27, 2014.

  1. #1
    Hello I have a depdent dropdown for country sate and city and i want to load states and cities based on country on document ready function i tried to put document.ready (function())

    but nothing works please update me how can i use this

    my code is here

    function showState(sel) {
        var country_id = sel.options[sel.selectedIndex].value; 
        $("#output1").html( "" );
        $("#output2").html( "" );
        if (country_id.length > 0 ) {
           
         $.ajax({
                type: "POST",
                url: "fetch_channel.php",
                data: "country_id="+country_id,
                cache: false,
                beforeSend: function () {
                    $('#output1').html('<img src="images/loading.gif">');
                },
                success: function(html) {   
                    $("#output1").html( html );
                }
            });
        }
    }
    
    function showCity(sel) {
        var state_id = sel.options[sel.selectedIndex].value; 
        if (state_id.length > 0 ) {
         $.ajax({
                type: "POST",
                url: "fetch_drama.php",
                data: "state_id="+state_id,
                cache: false,
                beforeSend: function () {
                    $('#output2').html('<img src="images/loading.gif">');
                },
                success: function(html) {   
                    $("#output2").html( html );
                }
            });
        } else {
            $("#output2").html( "" );
        }
    }
    
    Code (JavaScript):
     
    hallianonline, Nov 27, 2014 IP
  2. Naina S

    Naina S Active Member

    Messages:
    203
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    93
    #2
    Try putting breakpoint in page which is called by Jquery ajax function and see if breakpoint is reaching or not.
     
    Naina S, Dec 8, 2014 IP