javascript - jquery show loading in <select> - Stack Overflow

i have a jquery function that retrieves data from a php file and puts all that into a select list, whic

i have a jquery function that retrieves data from a php file and puts all that into a select list, which works just fine, the problem is that it takes some time to load and i wanted to show a loading text in the select while its loading, however it doesn't seem to work, here's what i've tried:

var modelSelect = $('[name="model"]'); // this is the select <select> list 

$('[name="make"]').on('change', function(){ // another <select> that fires up the ajax 
var chosen = $(this).val();

    $.ajax({

        type: "POST",
        url: "process.php",
        data: {'send': chosen},
        beforeSend: function(){
            modelSelect.html("loading"); //doesn't work
                },
        success: function(data){
            modelSelect.html(data);


        }

    });

});

any ideas how i can make it say loading there?

i have a jquery function that retrieves data from a php file and puts all that into a select list, which works just fine, the problem is that it takes some time to load and i wanted to show a loading text in the select while its loading, however it doesn't seem to work, here's what i've tried:

var modelSelect = $('[name="model"]'); // this is the select <select> list 

$('[name="make"]').on('change', function(){ // another <select> that fires up the ajax 
var chosen = $(this).val();

    $.ajax({

        type: "POST",
        url: "process.php",
        data: {'send': chosen},
        beforeSend: function(){
            modelSelect.html("loading"); //doesn't work
                },
        success: function(data){
            modelSelect.html(data);


        }

    });

});

any ideas how i can make it say loading there?

Share Improve this question asked Jan 29, 2014 at 15:15 user2209644user2209644 7111 gold badge10 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

Use this code instead

modelSelect.html("<option> loading ... </option>");

Hope it helps.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743778163a4505615.html

相关推荐

  • javascript - jquery show loading in &lt;select&gt; - Stack Overflow

    i have a jquery function that retrieves data from a php file and puts all that into a select list, whic

    7天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信