Quantcast
Viewing all articles
Browse latest Browse all 31594

bhattigurjot on "WordPress AJAX onchange event help"

I've drop down select menu which selects the branch. It is not in the form.

And I have included a action for it:

add_action( 'wp_ajax_the_ajax_hook_2', 'display_data_table' );

With the function that deals with database:

function display_data_table(){

$mno=$_POST['branch'];

//.. more code

}

Also my drop down menu html coding is:

<select name="branch" id="sel_branch" >

<option value="CSE">CSE</option>

// more options..

</select>

Now my jQuery script is like:

jQuery(document).ready(function(){

jQuery("#sel_branch").on('change', function(){

var dropdown_id=$(this).val();

jQuery.ajax({

type : "post",

url : the_ajax_script.ajaxurl,

data : {

action: "the_ajax_hook_2",

branch : dropdown_id

},

success: function(response_from_display_data_table) {

jQuery("#table_disp").html(response_from_display_data_table);

}

});

});

});

But it is not working. Am I doing something wrong here? Did I miss something?

@all.. if anyone's having any idea then please help.


Viewing all articles
Browse latest Browse all 31594

Trending Articles