位于0的JSON中出现意外的标记D. [英] Unexpected token D in JSON at position 0

查看:171
本文介绍了位于0的JSON中出现意外的标记D.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我创建了一个像这样工作的函数updateprintingqc()



用户将点击可点击的按钮更新数据

2.当用户点击确定时,将根据下图图片链接中显示的主要数据创建虚拟数据



我的错误



当用户第一次点击按钮时,功能正常。但是当用户第二次点击按钮时,会发生错误。



这是我在javascript中的编码:

Hi all,

I had created a function updateprintingqc() that work like this

user will click on a clickable button to update the data
2.when user click on OK,the dummy data will be create based on the main data shown in below image's link

My error

When the user click the button for the 1st time,the function work fine.But when the user click on the button for the 2nd time,error occur.

Here's my coding in javascript:

function updateprintingqc(this_, idschedule,idmsul,articleno,part_name,remain) {
  var conf = confirm("Are you choose to Update this Row of Record?");
    if (conf == true) {
        var url = "msp/updateqc?id=" + idschedule + "&idmsul=" + idmsul+"&articleno=" + articleno + "&part_name=" + part_name +"&remain="+remain ;
        $.ajax({
            type    : "get",
            url     : url,
            success : function(data) {
                var obj = jQuery.parseJSON(data);
                if (obj.status == 'Complete') {
                    displaymsg('Update Record', obj.msg);
                    oTable.fnStandingRedraw();
                }
            }
        });
    }
}





这里我的代码用php:





and here my code in php :

function updateqc() {
     $id        = $this -> input -> get('id', TRUE);
     $idmsul    = $this -> input -> get("idmsul");
     $articleno = $this -> input -> get("articleno");   
     $part_name = $this -> input -> get("part_name");   
     $remain       = $this -> input -> get("remain");
     $checking  = "select * from sindi_printing_qc_log where type='dummy'and idschedule='{$id}' ";
        $checkresult = count($this -> global_model -> query($checking) -> row());
        if($checkresult > 0 ){
            echo "Dummy already exist.";
        } else {
            $temp = array(
                "printing_log"=> 0,
                "idmsul"      => $idmsul,
                "articleno"   => $articleno,
                "part_name"   => $part_name,
                "qty"         => $remain,
                "pass"        => $remain,
                "reject"      => 0,
                "repaired"    => 0,
                "replaced"     => 0,
                "missing"     => 0,
                "procedure"   => 2,
                "addby"     => "LukeSkyWalker",
                "isvalid"     => 1,
                "updateby"    => "LukeSkyWalker",
                "updatedate" => date("y-m-d H:i:s"),
                "idschedule"  => $id,
                "type" => "Dummy"
            );
            $this -> db -> insert("sindi_printing_qc_log",$temp);
            $msg  = array('status' => 'Complete', 'msg' => 'Update Record ' . $id . ' Completed !');
            echo json_encode($msg);
        }
  }







请问有人可以帮助我解决这个问题吗? ?



谢谢。



我的尝试:



我试图在此错误上搜索类似主题并更改




Pls can anybody assists me for this problem??

Thanks.

What I have tried:

I have try to search for similar topic on this error and change the

var obj = jQuery.parseJSON(data);

到JSON.STRINGIFY(数据)

但仍然相同..



这应该是数据

to JSON.STRINGIFY(data)
but still the same..

this should be the data

{"aaData":[[1,"Back OD Band Pvc Sheet","0","0","0","0","Dummy"],[2,"Back OD Band Pvc Sheet","462","25","0","0","normal"],[3,"Back OD Band Pvc Sheet","496","14","6","8","normal"],[4,"Back OD Band Pvc Sheet","62","0","0","0","normal"]]}

推荐答案

.ajax({
type: get
url:url,
success: function (data){
var obj = jQuery.parseJSON(data);
if (obj.status == ' 完成'){
displaymsg(' 更新记录',obj.msg );
oTable.fnStandingRedraw();
}
}
});
}
}
.ajax({ type : "get", url : url, success : function(data) { var obj = jQuery.parseJSON(data); if (obj.status == 'Complete') { displaymsg('Update Record', obj.msg); oTable.fnStandingRedraw(); } } }); } }





这里我的代码用php:





and here my code in php :

function updateqc() {
     


id =
id =


this - >输入 - > get(' id',TRUE);
this -> input -> get('id', TRUE);


这篇关于位于0的JSON中出现意外的标记D.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆