我有 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]
有趣的是 html 代码在“html”标签之后与一些附加的 html 连接起来。我得到 index.php html 代码而不是 json。据我所知,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,成功或不失败块。可能是什么问题呢?