我想通过ajax加载.php文件,它们在加载时执行ExtJS脚本,这又会修改DOM中已有的ExtJS对象。为什么JavaScript不会在加载Ext.Ajax.Request的.php文件中执行?
但是,我甚至无法从通过Ext.Ajax.request
加载的页面执行Javascript。并且Firebug Net面板中没有显示错误。 PHP代码被执行,但不是Javascript。当我在浏览器中调用自己加载的页面时,它会执行Javascript罚款。
我怎样才能获得Javascript在执行页面加载Ext.Ajax.request?
Ext.onReady(function(){
var menuItemStart = new Ext.Panel({
id: 'panelStart',
title: 'Start',
html: 'This is the start menu item.',
cls:'menuItem'
});
var menuItemApplication = new Ext.Panel({
id: 'panelApplication',
title: 'Application',
html: 'this is the application page',
cls:'menuItem'
});
var regionMenu = new Ext.Panel({
region:'west',
split:true,
width: 210,
layout:'accordion',
layoutConfig:{
animate:true
},
items: [ menuItemStart, menuItemApplication ]
});
var regionContent = new Ext.Panel({
id: 'contentArea',
region: 'center',
padding:'10',
autoScroll: true,
html: 'this is the content'
});
new Ext.Viewport({
layout: 'border',
items: [ regionMenu, regionContent ]
});
menuItemStart.header.on('click', function() {
Ext.Ajax.request({
url: 'content/view_start.php',
success: function(objServerResponse) {
regionContent.update(objServerResponse.responseText);
}
});
});
menuItemApplication.header.on('click', function() {
Ext.Ajax.request({
url: 'content/view_application.php',
success: function(objServerResponse) {
regionContent.update(objServerResponse.responseText);
}
});
});
});
正在被通过Ajax加载的文件:
<script type="text/javascript">
window.onload=function() {
alert('from application view'); //is not executed
}
//Ext.onReady(function(){
// alert('from application view extjs'); //is not executed
//}
</script>
<?php
echo 'this is the application view at ' . date('Y-m-d h:i:s');
?>
这就是我原来的样子,但它也不执行,在Firebug Net面板中没有错误,就好像javascript被忽略了,我是否需要使用responseText以外的东西?但responseBody甚至不会出现PHP生成的内容 – 2010-12-02 09:25:18