-1

Is it possible to make an AJAX call that returns HTML and not have the browser also return all the associated resources (images, CSS etc)? I just want the HTML, but can see from the Network log that all the images are being retrieved too

$.ajax({
        url: theUrl,
        cache: false,
        accepts: "text/html"
    })

    .done(function(html) {
        // some parsing here

    });
paulusm
  • 786
  • 6
  • 19

1 Answers1

1

No, you can't. - If the url you're trying to fetch is within your application, then you may try some workarounds to achieve that, by :

1) Creating a separate url to return the HTML-only version

2) By loading images dynamically through script after the page is loaded, and control that behavior using a query-string or hidden value to trigger downloading of images.

  • If the url is not under your access i.e. in case of external links, you cannot do anything about it.

This question has some more hints: Prevent images from loading

MrClan
  • 6,402
  • 8
  • 28
  • 43