Vide: jQuery 3: error 'url.indexOf is not a function'

Getting an error when using Vide with JQuery 3.0.0.

Here is the no-minified stacktrace:

jQuery.Deferred exception: url.indexOf is not a function TypeError: url.indexOf is not a function
    at jQuery.fn.load (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js:9612:13)
    at findPoster (file:///Users/j/temp/test-site/js/jquery.vide.js:175:39)
    at Vide.init (file:///Users/j/temp/test-site/js/jquery.vide.js:280:7)
    at new Vide (file:///Users/j/temp/test-site/js/jquery.vide.js:219:12)
    at HTMLBodyElement.<anonymous> (file:///Users/j/temp/test-site/js/jquery.vide.js:461:18)
    at Function.each (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js:359:19)
    at jQuery.each (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js:152:17)
    at jQuery.$.fn.(anonymous function) [as vide] (file:///Users/j/temp/test-site/js/jquery.vide.js:454:10)
    at HTMLBodyElement.<anonymous> (file:///Users/j/temp/test-site/js/jquery.vide.js:497:28)
    at Function.each (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js:359:19) undefined

I was looking at it in the Chrome debugger it looks like the string being passed to $ in this line:

$('<img src="' + path + '.gif">').load(onLoad);

Is getting coerced into a function, which doesn’t have an indexOf function. Which blows up when it hits the first line in load.

jQuery.fn.load = function( url, params, callback ) {
    var selector, type, response,
        self = this,
        off = url.indexOf( " " );

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 24 (2 by maintainers)

Most upvoted comments

Better approach may be a polyfill like this

jQuery.fn.load = function(callback) { $(window).on("load", callback) };

Came here because of load() issues to learn that there is an issue that is not fixed. Time 12:10AM EST 10/25/2017

+2, has not been fixed in the bower version

+1, has not been fixed in the bower version

This has not been fixed in the bower version

Ah, looks like load is deprecated in jQuery 3.

From https://blog.jquery.com/2015/07/13/jquery-3-0-and-jquery-compat-3-0-alpha-versions-released/:

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

still not fixed in v. 3.2.1