简体   繁体   中英

Not sending ajax request to server in firefox

I am using this jquery code

   $("#tasksViewType").selectBox().change(
    function (){
        var userId = $('#hiddenUserId').val();
        var viewTypeId = $("#tasksViewType").val();

        $.post('updateViewType',{viewType:viewTypeId,userId:userId});
        location.reload(true);
    });

so this update the view type in database and then refresh the page but in firefox this is not working I tested in chrome and opera this is working fine.

I even tried to put the timer between the 3rd and 4th line but then it update the view type in database but not refresh the page autometically.

Please let me know if you need more detail.

Reload the page in the callback function. Otherwise, the page will reload before the server script has updated the database.

    $.post('updateViewType',{viewType:viewTypeId,userId:userId}, function() {
        location.reload(true);
    });

在文章中设置页面的扩展名。例如,如果您的页面是php类型,则如下所示

 $.post('updateViewType.php',{viewType:viewTypeId,userId:userId});

A possible reason could be the Cross-origin resource sharing restriction. In firefox, by default, Cross-site HTTP requests are restricted. You need to enable enable cross-origin resource sharing explicitly.

You may refer to the following links for more details.

how to get a cross origin resource sharing cors post request working

Enable CORS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM