Both of these are shortcuts to calling the ajax function. jQuery.get equivalent to:
$.ajax({ url: url, data: data, success: success, dataType: dataType });
So far, jQuery.getScript equivalent:
$.ajax({ url: url, dataType: "script", success: success });
It is easy to see that jQuery.get can get any type of response (script, xml, json, script or html - the default is html), and getScript limited to "script".
In short, getScript used to dynamically execute external JavaScript, and get is a general purpose function commonly used to receive data according to parameters passed. However, it is also possible to pass parameters to getScript (in the URL), but they will not be common since most scripts are static. Finally, callback in getScript can be used to execute final statements after executing our script (for example, after loading it, use some library function).
peewhy
source share