开发者

ajax not working on chrome (that worked in firefox) possibly due to event error

my script is not working on chrome but working perfectly on firefox

script is as follows and r_tour is the id of the select element and option is an option

$("#r_tour option").click(function(){
     var value = $(this).val(); $.post(      
        'url',
        {"id": value}, function(data){
        $(div).html(data);}, "html" ); 
})

and the link is here. on this link you will get the default value loaded from ajax (since ajax is called on document load) but (ajax requested event event will not load).

I think its possibly due to event but still don't have a clue.

UPDATE::

this piece of code is also not working on my localserver

$(function (){
$("#r_tour option").click(function(){
     var value = $(this).val(开发者_JAVA百科); 
     alert(value);
})
});


Can you verify whether or not this works for you? It should accomplish the same thing.

$("#r_tour option").click(function(){
     var value = $(this).val(); 
     $(div).load (url, 'id=' + uriEncodeComponent(value));
})

UPDATE

I see now. It seems like #r_tour is a select box, so why not just trigger this code when the value of the select box changes? Use $("#r_tour").change() instead of $("#r_tour option").click()

See http://jsfiddle.net/L5Ktr/1/

$("#r_tour").change(function(){
     var value = $(this).val(); 
     $(div).load (url, 'id=' + uriEncodeComponent(value));
})


You can try this:

$("#r_tour option").live("click", function(){
     var value = $(this).val(); 
     $(div).load(url, { id: value});
});

And this code ?:

$("#r_tour").live("click", function(){
     var value = $(this).val(); 
     alert(value);
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜