开发者

js doesn't work [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_C百科 Closed 11 years ago.

I have an rails application, yesterday I tested all my js and it worked fine, now I make some changes on it and js doesn't work correctly (the code from application.js doesn't execute correctly, the thickbox plugin still works fine), the funny thing is that I get my yesterday version from backup and now the same js problem appears, I check it in chrome and firefox4, anyone has some guesses?

js code:

$(window).load(function(){ 
var count;
$.getJSON("/carts/on_card", function(data){
    count = data;
    $("#products_count").text(count);   
}); 

$("#first_element").removeClass("page_item");
$("#first_element").addClass("current_page_item");
});

$(document).ready(function(){

var count;

$(".add_to_card").click(function(){     
    $.getJSON("/carts/on_card", function(data){
        count = 0;          
        count = data;           
    }); 

    $("#products_count").text(count);               
});

$(".removable").click(function(){
    $(this).remove();
});

$(".page_item").click(function(){
    $(".current_page_item").removeClass("current_page_item");
    $(".current_page_item").addClass("page_item")

    $(this).removeClass("page_item");
    $(this).addClass("current_page_item");
})
});


Are you familiar with the cache mechanism? Maybe you are seeing same results because the JS in the cache is still the incorrect one? Or in the other direction - the yesterday's version also contains a bug, but yesterday you were testing the page when the older (correct) JavaScript was still in the cache?

If cache is not the problem here, maybe some other script or HTML is currently different and interacts with the code in a different way than previously (some scripts require specific classes or attributes to be added to the elements they should process).

Anyway, did anything else change since it worked? Maybe you installed some plugin? Maybe you changed URLs? Maybe location of the script? Tell us more.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜