If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

(jQuery) loading images blindly

I've got image files named 0-0, 0-1, 0-2 and so on up to a certain point, and I want to load each file until it can't find another, hence the jquery ajax error. At the moment, this works in firefox only.

I don't think this could work at all? Putting an AJAX GET request in a while loop makes send you thousands of requests to the server in a few seconds, which cannot be answered as fast from the server, as your script executes.

The common approach is actually to store the basename (filename + extension) in a database. If you don't have a database, check how many files there are in the folder, pass this to JS and then create a for loop. Not with requests from JS!!!, but to build your img-tags dynamically.

Hmm, if you want to do this pure in JS, then you have to work with a callback. The error method is actually a callback, but when I test your code in Firefox, it sends thousands of requests, without waiting for the error callback.

But it is after midnight here, maybe (probably) there will be a solution.