Ask questions and get good answers on mb.jQuery.components

Hello,

Does $.getScript() have an error callback ?

In my case, i call gdata Youtube API in order to request data on a video. If the video exists, the request works fine, but it failed if video does not exists.

The classic $.getScript() callback (the 2nd argument callback) is called too late, after other script calls.

asked Oct 29 '09 at 13:15

Stf's gravatar image

Stf
462

edited Oct 29 '09 at 17:29

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129


The $.getScript() method doesn't have an error callback function; if your problem is that you doesn't get the script, the callback function of $.getScript would never be called than you should use the $.ajax method intead as shown ahead:

  $.ajax({
      type: "GET",
      url: "test.js",
      dataType: "script"
      error: function (XMLHttpRequest, textStatus, errorThrown) {},
      success:function(){ [function to call] }
   });

Otherwise if you have errors once the callback is called (and that means the script is on the page) than you should manage the error in your callback function.

answered Oct 29 '09 at 17:28

Matteo%20Bicocchi's gravatar image

Matteo Bicocchi ♦♦
1776129

edited Oct 29 '09 at 17:57

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×3
×1

Asked: Oct 29 '09 at 13:15

Seen: 949 times

Last updated: Feb 03 '10 at 16:26

jQuery main site - Matteo Bicocchi