Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not support populating values via ajax? #162

Open
softnayr opened this issue Aug 26, 2014 · 1 comment
Open

does not support populating values via ajax? #162

softnayr opened this issue Aug 26, 2014 · 1 comment

Comments

@softnayr
Copy link

I tried this code which gets data returned from ajax but it does not work:

$("#category_id option").remove(); // Remove all child tags.
$.each(data.message, function(index, item) {
$("#category_id").append($(item) );
});

@gyduxa
Copy link
Contributor

gyduxa commented Jan 11, 2016

The code below worked for me.

On change of one selectbox, the second gets populated.
The php file must contain the options of the second selectbox from the selected value of the first selectbox.

$('select.lvl1').selectBox().change(function () {
    $.ajax({
        method: "POST",
        url: 'populate.php',
        data: { cat: $('select.lvl1').val() },
        dataType: 'html'
    }).done(function(data) {
        $('select.lvl2').selectBox().setOptions(data);
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants