Skip to content

Instantly share code, notes, and snippets.

@tokkonopapa
Created June 11, 2011 09:15
Show Gist options
  • Save tokkonopapa/1020402 to your computer and use it in GitHub Desktop.
Save tokkonopapa/1020402 to your computer and use it in GitHub Desktop.
/echo/js/
/* /echo/js/ */
<div id="result">3秒後に赤に変わります</div>
$(function() {
// JavaScript コード (長いコードを一旦関数でくくる)
var code = function() {
$('#result').css('color', 'red');
}
// 関数オブジェクトを文字列、実行形式に変換し、URL エンコードする
var script = encodeURIComponent("(" + code.toString() + ")();");
// cache を有効にしないと {"_", "123456..."} が入る
$.ajaxSetup({
cache: true
});
// JavaScript をロードし、実行する
$.getScript("/echo/js/?delay=3&js=" + script).complete(function(jqXHR, statusText) {
console.log(statusText, jqXHR);
});
});
name: /echo/js/
description: /echo/js/ のテスト
authors:
- tokkonopapa
resources:
- https://getfirebug.com/firebug-lite-debug.js
normalize_css: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment