ajax请求返回jsp及javascript
发送ajax请求
$.ajax({
url: '/MyWayServer/getMyway!goMain.action',
type: "post",
dataType: "html",
success : function (data) {
alert(data);
$("#" + id).html(data);
},
error : function (data) {
alert('error');
}
});
返回的jsp是带javascript的如
<script src="<%=path%>/pages/myway/myway/grid.locale-en.js" type="text/javascript"></script>
页面可以显示但是看不到javascript,并且在tab中只能打开一个页面,打开多个无法执行脚本
请帮指点一下,谢谢
------解决方案--------------------把<script src="<%=path%>/pages/myway/myway/grid.locale-en.js" type="text/javascript"></script>写到你当前调用ajax那个页面去
------解决方案--------------------// 加载一个脚本文件
function _loadJsFile(url, callback) {
var script = document.createElement("script");
if(script.readyState) {
script.onreadystatechange = function() {
if(script.readyState == "loaded"
------解决方案-------------------- script.readyState == "complete") {
callback.call();
}
}
} else {
script.onload = callback;
}
script.type = "text/javascript";
script.async = true;
//+20130815
script.src = url;
//url.indexOf('?') != -1 ? url + '&v=' + version : url + '?v=' + version;
document.getElementsByTagName("head")[0].appendChild(script);
}