Questions tagged [jquery-load]

The .load() method in jQuery provides the ability to load content into the selected elements.

The .load() Load data from the server and place the returned HTML into the matched element.

.load( url [, data ] [, complete ] )

This method is the simplest way to fetch data from the server. It is roughly equivalent to $.get(url, data, success) except that it is a method rather than global function and it has an implicit callback function. When a successful response is detected (i.e. when textStatus is "success" or "notmodified"), .load() sets the HTML contents of the matched element to the returned data. This means that most uses of the method can be quite simple:

Example:

$( "#result" ).load( "ajax/test.html" );
319 questions
295
votes
14 answers

jQuery callback on image load (even when the image is cached)

I want to do: $("img").bind('load', function() { // do stuff }); But the load event doesn't fire when the image is loaded from cache. The jQuery docs suggest a plugin to fix this, but it doesn't work
Tom Lehman
  • 75,197
  • 69
  • 188
  • 262
144
votes
10 answers

Asynchronously load images with jQuery

I want to load external images on my page asynchronously using jQuery and I have tried the following: $.ajax({ url: "http://somedomain.com/image.jpg", timeout:5000, success: function() { }, error: function(r,x) { } }); But it…
Arief
  • 5,957
  • 7
  • 34
  • 41
30
votes
8 answers

jQuery ajax load not a function

This example
seemed to me like it is identical to the examples for…
Guillaume CR
  • 2,878
  • 1
  • 15
  • 30
21
votes
5 answers

Using jQuery load with promises

I'm still trying to wrap my head around deferred and what not, so with this in mind I have a question on how to do the following. My team and I have 3 separate .load() methods that each go grab a specific template and append that to the same…
Mike Fielden
  • 9,777
  • 14
  • 54
  • 93
18
votes
7 answers

How to cancel a jquery.load()?

I'd like to cancel a .load() operation, when the load() does not return in 5 seconds. If it's so I show an error message like 'sorry, no picture loaded'. What I have is... ...the timeout handling: jQuery.fn.idle = function(time, postFunction){ …
Dirk
  • 1,871
  • 1
  • 19
  • 25
15
votes
5 answers

Can jQuery .load append instead of replace?

I have a WordPress install and I'm trying to use jQuery to create a Load More effect. I'm having some trouble using the basic .load feature for page fragments. I don't mind using .get as I saw some threads here regarding that as a better…
Sahas Katta
  • 1,596
  • 3
  • 13
  • 23
12
votes
1 answer

Smooth image fade out, change src, and fade in with jquery

I am trying to do the following: On link click: 1.) fade out an img 2.) change the src of the now hidden image 3.) when the img with the new src finishes loading, fade in Minimally, I'd like to see a smooth fade out of one image and a fade in of…
Brian David Berman
  • 6,920
  • 23
  • 74
  • 143
10
votes
3 answers

Load a SPA webpage via AJAX

I'm trying to fetch an entire webpage using JavaScript by plugging in the URL. However, the website is built as a Single Page Application (SPA) that uses JavaScript / backbone.js to dynamically load most of it's contents after rendering the initial…
KyleMit
  • 45,382
  • 53
  • 367
  • 544
9
votes
1 answer

Jquery load select a specific class

So I am using Jquery's load function like so, $('#id').load("http://www.thisiswhyimbroke.com"); I know you can add id selectors after the url, but the content im looking for is not contained within an id, is there a way I can select a particular…
Jupiter
  • 238
  • 1
  • 2
  • 11
9
votes
2 answers

.load() and relative paths

.load() is giving me trouble. I'm working on a section loader project and I just can't seem to fetch the file that I need. What I am trying to achieve: #sectionContainer is empty on document load, but on document ready it is 'filled' with…
Bram Vanroy
  • 22,919
  • 16
  • 101
  • 195
8
votes
3 answers

JQuery replace entire DIV using .load()

I want to refresh a
on the close of a jQuery UI Modal Dialog. My code is: var dialog = jQuery('#divPopup').dialog({ autoOpen: false, height: 450, width: 650, modal: true, open: function(event, ui) { …
AliMan
  • 107
  • 1
  • 2
  • 10
7
votes
3 answers

Jquery Load Part of External HTML

Basicily i have a index.html shown below.. UI Test: Main Menu
Lemex
  • 3,646
  • 14
  • 47
  • 82
6
votes
3 answers

How can jQuery .load fail?

I am using a simple ajax loader to get content on wordpress. $("#page_preview").load("ajaxloader/", function(response, status, xhr) { if (status == "error") { alert("Sorry but there was an error"); } else { …
Odys
  • 8,319
  • 8
  • 63
  • 105
6
votes
2 answers

Scripts running in jquery.ajax() loaded pages run document.ready too early

My site was using jquery.load() to do navigation on a big chunk of the page. I really appreciate the ability to only include only a particular part of the loaded content, here the div with id="content": $(frame_selector).load(url +" #content",…
Leopd
  • 37,882
  • 29
  • 117
  • 156
6
votes
2 answers

Show loading image while PHP is executing

I would like to show loading image while the php script is executing. I have read different answers on how to do that but most of them stated that I should have a separate php page. However I am using single page to show the rows, so how can I be…
Lmxc
  • 255
  • 2
  • 6
  • 17
1
2 3
21 22