We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var jsonP = (function(){ var root = this; var param2query = function(data){ var query = "?"; for(var k in data){ if(!data.hasOwnProperty(k)) break; query+= (k)+"="+(data[k])+"&"; } return query; }; return function(url, option){ var data, callback; if ("[object Object]" == Object.prototype.toString.call(url)) { url = url.url; data = url.data; callback = url.callback; }else{ data = option.data; callback = option.callback; } var jsonPCallbackName = "jsonP" + new Date().getTime(); url = url.replace(/\?$/,"") + param2query(data); url += "callback=" + jsonPCallbackName; var script = document.createElement("script"); script.src = url; root[jsonPCallbackName] = function(data){ callback.call(jsonP, data) delete root[jsonPCallbackName]; document.body.removeChild(script) } document.body.appendChild(script); } }).call(this); jsonP("https://passport.58.com/wukong/userstate", { data: { user: "cat", pword: "any" }, callback: function(data) { console.log(data) } })
少个umd封装
The text was updated successfully, but these errors were encountered:
if(!data.hasOwnProperty(k)) break; 为什么要 break ?
if(!data.hasOwnProperty(k)) break;
break
Sorry, something went wrong.
我不太喜欢
if(true){ //todo if(true){ //todo } } //习惯这样 if (!false) return if (!false) break if (!false) continue
No branches or pull requests
少个umd封装
The text was updated successfully, but these errors were encountered: