wordpress dependent drop down list using post type is not working in ajax.
I need a ddl value from another ddl in post type.
i have 2 post type department and doctors, when i select a department in drop down list i need the doctors in that department using ajax and not by refresh
ajax
$('#dpt').change(function () {
var dpt = $(this).val();
jQuery.ajax({
type: 'post',
data: {id: dpt},
success: function (data) {
// alert(data);
$('#response').text('dpt : ' + data);
}
});
});
wordpress dependent drop down list using post type is not working in ajax.
I need a ddl value from another ddl in post type.
i have 2 post type department and doctors, when i select a department in drop down list i need the doctors in that department using ajax and not by refresh
ajax
$('#dpt').change(function () {
var dpt = $(this).val();
jQuery.ajax({
type: 'post',
data: {id: dpt},
success: function (data) {
// alert(data);
$('#response').text('dpt : ' + data);
}
});
});
PHP
Select Doctors 'doctors', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'dptmnt', 'value' => $dpt, 'compare' => 'LIKE' ), 'order' => 'ASC' ), ); $events = new WP_Query($args); while ($events->have_posts()): $events->the_post(); ?> ">HTML
Select Department 'dpt', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ); $events = new WP_Query($args); while ($events->have_posts()): $events->the_post(); ?> ">AJX
$(function () { $("select[name='dp']").change(function () { var str = ""; $("select[name='dp'] option:selected").each(function () { str += $(this).text() + " "; }); jQuery.ajax({ type: "POST", data: $("form#a").serialize(), success: function (data) { // alert(data); // jQuery(".res").html(data); $('#doc').html(data); } }); var str = $("form").serialize(); // $(".res").text(str); }); });This work for me