locked
Window.Location.href method doesnot fire RRS feed

  • Question

  • User491718545 posted

    Hi,

    window.location.method wont fire when using Ajax..

      <input value="Continue" class="button" id="btnSubmit" type="submit"/>

    $('#btnSubmit').on('click', function () {

    $.ajax({
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    url: 'EditAccountInformation.aspx/InsertMethod',
    data: "{'FirstName':'" + $('#<%=txt_firstName.ClientID%>').val() + "', 'LastName':'" + $('#<%=txt_LastName.ClientID%>').val() + "','Email':'" + $('#<%=txt_Email.ClientID%>').val() + "','Phone':'" + $('#<%=txt_telephone.ClientID%>').val() + "'}",
    async: false,

    success: function (response) {
    $('#btnSubmit').prop('disabled', false);
    $('#btnSubmit').prop('value', 'Add New');

    if(response.d=="Saved Successfully")

    {
    window.location.href = "DetailsMaster.aspx";---Event doesnot fire

    }
    e.preventDefault();

    },
    error: function ()
    { console.log('there is some error'); }
    });

    });

    Thanks

    Monday, December 2, 2013 7:04 AM

Answers

All replies

  • User753101303 posted

    Hi,

    Do you use async:false on purpose ? What don't you use an async call ? I've seen this several times and it seems that callbacks are not fired when doing a sync call (in this case you would likely just put your code directly after the synchronous call).

    Edit : use the javascript debugger to see if you ever hit the callback.

    Monday, December 2, 2013 7:23 AM
  • User-484054684 posted

    window.location.href = "DetailsMaster.aspx";---Event doesnot fire

    Also try following:

    1. window.location.assign("DetailsMaster.aspx");
    Or
    2. window.location = "DetailsMaster.aspx";

    Reference: http://stackoverflow.com/questions/14213737/window-location-href-on-ajax-success-not-working

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 2, 2013 7:30 AM