我在firebug控制台中获得了index.php html

时间:2012-07-13 12:57:13

标签: php javascript extjs

我有ext js面板组件,当提交它时会在firebug控制台中抛出js错误。 我说

 'You're trying to decode an invalid JSON String: <html>

         ... index.php html code here

  </html><!-- use login javascript file --> <!--<script type="text/javascript"    src="http://localhost:9808/recorder/js/login.js"></script>--> 
   <script type="text/javascript">      
        login = true; 
   </script> 
   <div id="login_window"> </div>' when calling method: 
        [nsIDOMEventListener::handleEvent]

Intersting是html代码在“html”标记之后与某些additinal html连接。我得到index.php html代码而不是json。至于我knwo check()函数我只调用ecoes json数据。

我的组件代码是这样的

     login_group_combo = Ext.create('Ext.form.ComboBox',
   {
    name: 'combo_name',
    id: 'combo_id',
    fieldLabel: text_label,
    editable: false,
    //possible view options
    store: [
    ],
    listeners:
    {
        focus: function(elem, e)
        {
                function1();
        }
    }
});

function1()看起来像这样

   function function1(){
      form1.submit({
         url: './index.php/mypage/check',
         success: function(f,a){
             // some code here
             echo json_encode($result_array);
         },
         failure: function(form, action){
            switch (action.failureType) {
               case Ext.form.action.Action.CLIENT_INVALID:
                   Ext.Msg.alert('Failure', 'Invalid data entered!');
                    break;
               case Ext.form.action.Action.CONNECT_FAILURE:
                   Ext.Msg.alert('Failure', 'Ajax communication failed');
                   break;
               case Ext.form.action.Action.SERVER_INVALID:
                  Ext.Msg.alert('Failure', action.result.msg);
             }
          }
      });
   }

有趣的是执行进入function1();但不进入form1,成功或不进入faulire块。可能是什么问题?

1 个答案:

答案 0 :(得分:2)

如果您在浏览器中加载./index.php/mypage/check并查看源代码,您会看到json或html吗?通常服务器框架中的某些内容是通过页眉和页脚布局代码或者类似的方式放入html,并且需要设置一些配置,以便您可以返回原始的json字符串。