10 examples of 'jquery cdn ajax' in JavaScript

Every line of 'jquery cdn ajax' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
2function createAjax() {
3 let httpRequest;
4 if (window.XMLHTTPRequest) {
5 httpRequest = new XMLHttpRequest();
6 }else if(window.ActiveXObject){
7 httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
8 }
9 return httpRequest;
10}
17function loadjQuery(url, callback) {
18 var script_tag = document.createElement('script');
19 script_tag.setAttribute("src", url)
20 script_tag.onload = callback; // Run callback once jQuery has loaded
21 script_tag.onreadystatechange = function () { // Same thing but for IE... bad for IE 10, it supports all
22 if (this.readyState == 'complete' || this.readyState == 'loaded') {callback();}
23 }
24 script_tag.onerror = function() {
25 loadjQuery("http://code.jquery.com/jquery-1.8.2.min.js", main);
26 }
27 document.getElementsByTagName("head")[0].appendChild(script_tag);
28}
57set ajax (url) { this.setAttribute('ajax', url) }
24function loadJQuery() {
25 if(!window.jQuery) {// load only if its required as it is giving problem on many pages.
26 addLibrary("/thirdparty/pratikabu-jquery.js", function(result) {
27 eval(result);
28 pratikabusttjquery = window.jQuery.noConflict(true);// this line will replace any existing mapping of $ and jQuery on the current page
29 loadCompleteFile();
30 });
31 } else {
32 pratikabusttjquery = window.jQuery;
33 loadCompleteFile();
34 }
35}
3function ajax(url,param,type,dataType,callBack){
4 var html='';
5 var type=type || 'post';
6 var dataType=dataType || 'JSON';
7 $.ajax({
8 url:url+'?random='+Math.round(Math.random()*100),
9 contentType:'application/json;charset=utf-8',
10 data:JSON.stringify(param),
11 type:type,
12 dataType:dataType,
13 beforeSend:function(){
14 //开始发送数据时在页面正在显示加载动画
15 $('body').append('<div></div>');
16 },
17 //请求结束用complaste结束加载提示。
18 complete:function(){
19 $('#pload').remove()
20 },
21 success:function(res){
22 if(res.retCode==0){
23 callBack(res);
24
25 }
26 },
27 error:function(res){
28 // console.log(1,res);
29 }
30 })
31 }
51function getCdnUrl(url) {
52 return '//mib.bdstatic.com/doc/detail/' + encodeURIComponent(url) + '/0/#from=sub';
53}
3function ajaxGet(url, callback) {
4 var req = new XMLHttpRequest();
5 req.open("GET", url);
6 req.addEventListener("load", function () {
7 if (req.status &gt;= 200 &amp;&amp; req.status &lt; 400) {
8 // Appelle la fonction callback en lui passant la réponse de la requête
9 callback(req.responseText);
10 } else {
11 console.error(req.status + " " + req.statusText + " " + url);
12 }
13 });
14 req.addEventListener("error", function () {
15 console.error("Erreur réseau avec l'URL " + url);
16 });
17 req.send(null);
18}
195function ajax(url, settings) {
196
197 var ccb, config, defaults;
198
199 if (!url) {
200 throw "PRECONDITION ERROR: url required with AJAX call";
201 }
202 if (!settings || !$$.isFunction(settings.success)) {
203 throw "PRECONDITION ERROR: function: 'settings.success' missing.";
204 }
205 if (! validateClient(settings.client, settings.success)) {
206 return;
207 }
208
209
210 ccb = settings.success;
211 defaults = {
212 method: 'GET',
213 async: true,
214 contentType: "application/json",
215 headers: {"Authorization" : "OAuth " + settings.client.oauthToken,
216 "Accept" : "application/json"},
217 data: null
218 };
219 config = $$.extend(defaults, settings || {});
220
221 // Remove any listeners as functions cannot get marshaled.
222 config.success = undefined;
223 config.failure = undefined;
224 // Don't allow the client to set "*" as the target origin.
225 if (config.client.targetOrigin === "*") {
226 config.client.targetOrigin = null;
227 }
228 else {
229 // We need to set this here so we can validate the origin when we receive the call back
230 purl = startsWithHttp(config.targetOrigin, purl);
231 }
232 postit(ccb, {type : "ajax", accessToken : token, url : url, config : config});
233}
34function cdnImage (url, width) {
35 return 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=' + url + '&amp;container=focus&amp;refresh=2592000&amp;resize_w=' + width
36}
75function $ajax(url, params, cb,type){
76 $.ajax({
77 url: url,
78 data:params,
79 type: type?type:'post',
80 success: function(data) {
81 var ret = data.ret;
82 switch(ret){
83 case 0://成功
84 //执行成功回调函数.
85 cb(data);
86
87 break;
88 default ://没有登陆态或登陆态失效
89 alert(data.msg);
90 }
91 },
92 error: function() {
93 }
94 });
95}

Related snippets