Harry
Harry

Reputation: 4773

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.

Upvotes: 0

Views: 173

Answers (3)

Jacob Nelson
Jacob Nelson

Reputation: 2476

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

Upvotes: 0

Barmar
Barmar

Reputation: 781058

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);
    });

Upvotes: 3

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

Set the extension of your page in the post.Like if your page is php type then give it like the following

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

Upvotes: 0

Related Questions