jquery ajax在调用之后将无法工作

时间:2022-10-08 12:01:09

The following jquery won't work as it was called by another set of ajax. The radio buttons show, but upon selected, it won't open up the URL calendar.html. However, if I tried to open this file without having it called by another set of ajax, it works perfectly fine and the URL calendar.html opens up beautifully.

以下jquery将无法工作,因为它被另一组ajax调用。单选按钮显示,但选中后,它将不会打开URL calendar.html。但是,如果我尝试打开此文件而没有通过另一组ajax调用它,它可以正常工作,并且URL calendar.html打开了漂亮。

Can someone help? I've heard of bind and live but don't know enough to incorporate it successfully. Thank you

有人可以帮忙吗?我听说过bind和live但是不太了解它是否成功地将它合并。谢谢

$(document).ready(function() {

$('.button').click(function() {
    var valueSelected = this.value;
    var buttonSelected = this.id.replace(valueSelected + '_','');
    //alert('Button Selected: ' + buttonSelected + "\nValue Selected: " + valueSelected);
    $.ajax({

    url: 'calendar.html',           
        data:  '',
        cache: false,
    async: false,
        success: function(result) {
            $('#ajaxDiv').html(result);


        },
        error: function (response, desc, exception) {
            // custom error
        }
    });

});

});

1 个解决方案

#1


0  

Well, for starters you don't need the data attribute, it is empty by default.

好吧,对于初学者,你不需要数据属性,默认情况下它是空的。

There aren't any errors that are popping right out at me, but you should make sure that you have the right path to calendar.html (be sure it is relative to the .html document that the JavaScript is loaded into).

没有任何错误突然出现在我面前,但你应该确保你有正确的calendar.html路径(确保它是相对于加载JavaScript的.html文档)。

#1


0  

Well, for starters you don't need the data attribute, it is empty by default.

好吧,对于初学者,你不需要数据属性,默认情况下它是空的。

There aren't any errors that are popping right out at me, but you should make sure that you have the right path to calendar.html (be sure it is relative to the .html document that the JavaScript is loaded into).

没有任何错误突然出现在我面前,但你应该确保你有正确的calendar.html路径(确保它是相对于加载JavaScript的.html文档)。