toi kết hợp jquery + ajax + json trong viễt code thì gặp lỗi parseJSON: filter failed
đoạn code thế này:
Mã:
<script src="libs/jQuery/jquery.js" language="javascript" type="text/javascript"></script>
<script src="libs/jQuery/json.js" language="javascript" type="text/javascript"></script>
<script src="libs/jQuery/ajax.js" language="javascript" type="text/javascript"></script>
<script src="libs/jQuery/jquery.form.js" language="javascript" type="text/javascript"></script>
<script>
if (typeof jsCategory == 'undefined') {
var objCategory = {
addCate: function() {
var src = "index.php?json=1";
//alert(src);
$.ajax({
type: "POST",
url: src,
//dataType: 'JSON',
data: $('#fmAddCate').serialize(),
success: function(xmlhttp){
var objData = xmlhttp.parseJSON();
if ((parseInt(objData.intIsOk) > 0) || (objData.intIsOk == true)) {
alert("Thêm mới thành công");
} else {
alert(objData.aryError);
}
$('#fmAddCate').unbind('button');
},
error: alert("Loi gi day"),
});
}
/*
addCate: function() {
//alert("Thêm mới thành công");
var src = "?json=1";
//alert(src);
var options = {
success:function(responseText, status){
if ((parseInt(responseText.intIsOk) > 0) || (responseText.intIsOk == true)) {
alert("Thêm mới thành công");
} else {
alert(responseText.aryError);
}
$('#fmAddCate').unbind('submit');
},
error: alert("Loi gi day"),
url: src,
type: 'POST',
dataType: 'json'
};
$('#fmAddCate').ajaxForm(options);
}
*/
};
}
</script>
<?php
$json = @$_GET['json'];
if ($json == 1) {
$ary = array();
$ary['intIsOk'] = 0;
$ary['aryError'] = "Gặp lỗi ở đây";
echo json_encode($ary);
exit();
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div new categories</div>
<div style="display:block; border-top:dotted 1px"></div>
<form name="fmAddCate" id="fmAddCate" action="" method="post" enctype="multipart/form-data">
<div style="float:left; width:100%">
<input type="text" name="txtName" id="txtName" value=''/>
<div>
<div style="padding-left:20%; width:100%; padding-bottom:20px">
<input type="button" value="Add" name="Add" onclick="objCategory.addCate()"/>
<input type="reset" value="Reset"/>
</div>
</div>
</div>
</form>
prô php giúp với :ym_sad:
thank
Tôi đã sở hữu một chiếc Lush 3 trong 18 tháng, đã ở cả hai phía của việc kiểm soát máy rung công cộng và nhận ra rằng nó không phải là máy rung tốt nhất cho mọi dịp. Đánh giá Lush 3 này dựa trên trải...
Mọi Điều Cần Biết Về Lovense Lush 3 Qua 6 Câu Hỏi Đơn Giản