Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138279

How to use jQuery ajax to check if file exists in JS array?

$
0
0

I have an array urlResult which collects the href attribute of all a elements on a component. Looks like:

enter image description here

All I need to do is use jQuery $.ajax() method to check against those URL's and in each callback do something if there is success or failure. So I was thinking of something like:

$.ajax({
    url: urlResult[i] // somehow use dynamic variable?
    type:'HEAD',
    error: function()
    {
        //file not exists
    },
    success: function()
    {
        //file exists
    }
});

I just need some guidance on how to dynamically include urlResult variable and pass each index to url property in ajax call.


Viewing all articles
Browse latest Browse all 138279

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>