一个页面调用可以在这个网址远程脚本:http://url.to.script/myScript?ScriptParamsList
。让我们假设:不需要
- 异步执行。
- 显示输出不是必需的。
脚本在按钮单击事件上调用。让处理程序()是JavaScript的事件处理程序:
function Handler() { //invoke the remote script }
有几种方法可以实现处理程序()函数:
- 脚本VS img标签:
document.write('<script src="http://url.to.script/myScript?ScriptParamsList" type="text/javascript"></script>');
document.write('<img src="http://url.to.script/myScript?ScriptParamsList" />');
- jQuery的html的()与.load():
$('#TargetDiv').html('<img src="http://url.to.script/myScript?ScriptParamsList" />');
$('#TargetDiv').load('http://url.to.script/myScript?ScriptParamsList');
问题
哪些是优点和缺点?
''?你的意思是''?顺便说一下,你正在比较苹果和橘子...... –
2012-07-18 14:07:15
@Rob W:编辑。谢谢。 – 2012-07-18 14:10:10