2012-07-13 41 views
1

我有ext js面板组件,当它被引用时它会在萤幕控制台中抛出js错误。 我说我在firebug控制台得到index.php html

'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] 

野趣是html代码获得与“HTML”标签后,一些additinal HTML级联。并且我得到了index.php html代码而不是json。至于我knwo check()函数,我只称eco只有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(); 
     } 
    } 
}); 

功能1()看起来像这样

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); 
      } 
      } 
     }); 
    } 

的野趣的事情是,执行进入功能1();但没有输入form1,成功或者没有faulire块。可能是什么问题呢?

+0

您的代码中缺少一些右括号 – Timmetje 2012-07-13 13:05:43

+0

我试图找不到括号,您的意思是form_check_user()中的那个。不,这不是问题。我再次检查了我的代码,我使用Aptana。它会告诉我如果我丢失括号。 – Vlad 2012-07-13 13:11:37

+0

为什么它会转储整个index.php html代码而不是json。 – Vlad 2012-07-13 13:12:24

回答

2

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

相关问题