开发者

how to fire jquery load function after using change function

开发者 https://www.devze.com 2023-03-13 09:29 出处:网络
I have a dropdown list where i want to fire load function after user changes option in dropdown list , please help

I have a dropdown list where i want to fire load function after user changes option in dropdown list , please help

var x = $("#catid");

x.change(function(){
    var y = $('#catid option:selected').val();
    var url = "<?php echo base_url();?>index.php/";
    window.locati开发者_C百科on= url+"master/posting/create/"+ y;


});

my main purpose here is to get rid off window.location and do that with load function to see select option in second menu. Thanks


If you want to visit another url then there is no reason to change what you have. Using window.location is how you achieve that.


Assuming that $("#catid") is the ID of the select box and let us assume a container $("#result") for the content of the load:

$("#catid").change(function(){
     var y = $(this).val();
     var url = "<?php echo base_url();?>index.php/";
     $("#result").load(url+"master/posting/create/"+ y);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消