{"action":"closed","issue":{"url":"https://api.github.com/repos/bfchengnuo/WEB_learn/issues/4","repository_url":"https://api.github.com/repos/bfchengnuo/WEB_learn","labels_url":"https://api.github.com/repos/bfchengnuo/WEB_learn/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/bfchengnuo/WEB_learn/issues/4/comments","events_url":"https://api.github.com/repos/bfchengnuo/WEB_learn/issues/4/events","html_url":"https://github.com/bfchengnuo/WEB_learn/issues/4","id":339151632,"node_id":"MDU6SXNzdWUzMzkxNTE2MzI=","number":4,"title":"JS 动态加载脚本？","user":{"login":"bfchengnuo","id":16206117,"node_id":"MDQ6VXNlcjE2MjA2MTE3","avatar_url":"https://avatars3.githubusercontent.com/u/16206117?v=4","gravatar_id":"","url":"https://api.github.com/users/bfchengnuo","html_url":"https://github.com/bfchengnuo","followers_url":"https://api.github.com/users/bfchengnuo/followers","following_url":"https://api.github.com/users/bfchengnuo/following{/other_user}","gists_url":"https://api.github.com/users/bfchengnuo/gists{/gist_id}","starred_url":"https://api.github.com/users/bfchengnuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfchengnuo/subscriptions","organizations_url":"https://api.github.com/users/bfchengnuo/orgs","repos_url":"https://api.github.com/users/bfchengnuo/repos","events_url":"https://api.github.com/users/bfchengnuo/events{/privacy}","received_events_url":"https://api.github.com/users/bfchengnuo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-07T14:53:41Z","updated_at":"2018-07-18T03:39:45Z","closed_at":"2018-07-18T03:39:45Z","author_association":"OWNER","body":"问题来源：jQuery 的 JSONP 是如何实现的呢？\r\n动态添加 script 标签就能发起请求？\r\n\r\n---\r\n\r\n临时笔记：\r\n### 写入新的标签\r\n`document.write` 会重载界面，加载方式为异步加载，就是说如果使用 write 来往页面写一个 script 标签，它会一边继续执行后面的代码，一边额外开一个线程执行需要加载的脚本；如果调用这里面的代码，由于加载完成时间的不确定性，可能会失败。\r\n另外，使用动态创建的方法也基本一样（createElement）；\r\n但是可以使用 appendChild 方法写入加载完后要执行的代码，这样一来就相当于是同步了。\r\n同步的方式还有 ajax 的方式，请求内容后拼装在 script 标签里就行了，但是这种方式不支持跨域。\r\n### 修改已有标签的 src\r\n这样页面不会重载，但是依然还是异步加载，无法保证加载完成的时间。\r\n解决这种问题可以考虑使用回调的方法。"}}
{"actor":{"display_login":"bfchengnuo"}}