2010-12-02 23 views
2

this answerのおかげで、私はExtJS AJAX呼び出しでロードされたときにjavascriptを実行することができました。javascript evalはchrome、safariで動作しますが、Firebugがオンの場合のみFirefoxで動作しますか?

ただし、次のコードは、(Macの場合)すべてのブラウザで同じように動作しません。

  • クローム:作品、アラートが
  • サファリをポップアップ表示:作品、アラートが
  • Firefoxのポップアップ表示します:作品、が、Firebugのは、Firebugのが有効でない場合、スクリプトは
  • 私はjavascを取得できますか

を無視し、を有効になっている場合にのみ、 FirebugをインストールせずにFirefoxでAJAX呼び出しを実行するには?

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) { 
       var responseText = objServerResponse.responseText; 
       console.log(responseText); 
       regionContent.update(responseText); 
       var scripts, scriptsFinder=/<script[^>]*>([\s\S]+)<\/script>/gi; 
       while(scripts=scriptsFinder.exec(responseText)) { 
        eval(scripts[1]); 
       } 
      } 
     }); 

    }); 
}); 

ロードされているベース:

<script type="text/javascript"> 
    alert('inside application view'); 
</script> 
<?php 
echo 'this is the application view at ' . date('Y-m-d h:i:s'); 
?> 

答えて

1

console.logがあなたの犯人です。

あなたはJavaScriptでログインしているときはいつでも、それはコンソールが、それは機能です呼び出す前に存在しているかどうかを確認することをお勧めします:

if(window.console) console.log('whatever'); 

その方法コンソールが利用可能になったとき、それだけで実行されます。

3
console.log(responseText); 

この行は私のために問題と思われます。 consoleは、Firebugがオンの場合にのみ存在するため、コメントするか、使用する前に存在するかどうかを確認する必要があります。

+0

そこにあったことを忘れてしまった:-)、そしてそれがFirefoxの問題を引き起こすことを知っておくと便利です。ありがとう –

0

console.logを削除するかどうかはわかりませんが、loadScriptsの設定についてはother answerもご覧ください。

関連する問題