XMLHttpRequest causing page refresh

Last post 07-03-2009 9:31 AM by bigsby. 4 replies.

Sort Posts:

  • XMLHttpRequest causing page refresh

    06-30-2009, 2:09 PM
    • Member
      13 point Member
    • bigsby
    • Member since 07-19-2007, 11:14 AM
    • Lisboa, Portugal
    • Posts 4

    Here it goes...maybe on of you has been here before.

    Scenario:

    -I have an ASP Web Application with a MasterPage that holds an iframe.

    -On this MasterPage I have an UserControl that holds some ASP buttons that trigger, directly from javascript, some XMLHttpRequests to a ASPX for information refreshing.

     

    Symptom:

    - Each time the request is complete, the whole page gets refreshed.

     

    Tests already made:

    - Return false, in every method involving the pre and pos-request.

    - Set UseSubmitBehavior to false in the buttons. 

     

    Any ideas?

  • Re: XMLHttpRequest causing page refresh

    06-30-2009, 3:57 PM
    • Contributor
      4,575 point Contributor
    • mpaterson
    • Member since 11-26-2006, 10:24 PM
    • Ipswich, MA
    • Posts 1,298

    Have you tried using an HTML button instead of an asp.net button?  asp.net buttons have "__doPostBack" which is what's causing the postback.

    If everything happens for a reason what is the reason for this error?
  • Re: XMLHttpRequest causing page refresh

    07-01-2009, 6:31 AM
    • Member
      13 point Member
    • bigsby
    • Member since 07-19-2007, 11:14 AM
    • Lisboa, Portugal
    • Posts 4

    Thanks for the reply.

    I spent 2 hours yesterday around this and it took me 2 minutes today to realize that the JSON string in the responseText wasn't correctly built. Why was this causing a page refresh? Beats me.

     

    Best regards.

  • Re: XMLHttpRequest causing page refresh

    07-01-2009, 7:55 AM
    Answer
    • Contributor
      4,575 point Contributor
    • mpaterson
    • Member since 11-26-2006, 10:24 PM
    • Ipswich, MA
    • Posts 1,298

    If this was causing a javascript error then it makes sense.  The execution of the javascript would stop and prevent "return false" from being called.

    If everything happens for a reason what is the reason for this error?
  • Re: XMLHttpRequest causing page refresh

    07-03-2009, 9:31 AM
    • Member
      13 point Member
    • bigsby
    • Member since 07-19-2007, 11:14 AM
    • Lisboa, Portugal
    • Posts 4

     On the money, m.

Page 1 of 1 (5 items)