How to load XMLHttpRequest?

Is it possible to abort() a jQuery load()?

  • I'm using load() to get page fragments and the XMLHttpRequest object doesn't seem to be available until the callback (which is too late, obviously). Conversely, is there a way to load a page fragment (via jQuery selector) using $.get()?

  • Answer:

    Yes, $.get() will do the trick. The browser's innerHTML parses the html response of such a call, so you just need to shove the response into a dummy DOM node. This is precisely the implementation of .load(). So you need your $.get() callback to do something like: function(resHTML) { $('#target').html( $("<div />") .html( resHTML.replace(/<script(.|\s)*?\/script>/gi, "") ) .find("#content") ); }

Evan Q Jones at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.