Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery VM2289:3未捕获的语法错误:Function.parse[作为parseJSON](<;anonymous>;)处的JSON输入意外结束_Jquery_Sql Server_Jsp - Fatal编程技术网

Jquery VM2289:3未捕获的语法错误:Function.parse[作为parseJSON](<;anonymous>;)处的JSON输入意外结束

Jquery VM2289:3未捕获的语法错误:Function.parse[作为parseJSON](<;anonymous>;)处的JSON输入意外结束,jquery,sql-server,jsp,Jquery,Sql Server,Jsp,朋友们好,我是jquery的新手,请帮助我。 我有两个jsp文件“index.jsp”和“DatabaseFile.jsp”。我必须在“databasefile.jsp”中获取数据库数据,并将这些数据发送到“index.jsp”页面,并在“index.jsp”中的单独文本框中显示FName、LName、Contactno。为此,我在“index.jsp”页面中使用了jquery的$.post() 这是jquery在“index.jsp”中的代码 这是“databasefile.jsp”的代码 i

朋友们好,我是jquery的新手,请帮助我。 我有两个jsp文件“index.jsp”和“DatabaseFile.jsp”。我必须在“databasefile.jsp”中获取数据库数据,并将这些数据发送到“index.jsp”页面,并在“index.jsp”中的单独文本框中显示FName、LName、Contactno。为此,我在“index.jsp”页面中使用了jquery的$.post()

这是jquery在“index.jsp”中的代码

这是“databasefile.jsp”的代码

intid=Integer.parseInt(request.getParameter(“number”);
试一试{
String query1=“选择count(*)作为详细信息中的总计,其中ID=”+
id+“'”;
结果集rs=st.executeQuery(查询1);
int ttl=0;
如果(rs.next())
{               
ttl=rs.getInt(“总计”);
}

如果(ttlDid)您调试并检查返回的JSON值是什么?您能在这里共享该值吗?我不知道如何检查它这是我第一次使用JSON..抱歉,兄弟,请帮助您知道如何调试java代码吗?您正在使用哪个代码编辑器?在解析数据之前尝试提醒数据。我正在使用eclipseDid您调试代码吗?
$('.confirm').click(function(){
        var no = $('#id').val();
        $.post("DatabaseFile.jsp",{number:no},function(data)
            {
                var newdata = $.parseJSON(data);
                    $.each(newdata, function(i, element) 
                    {
                        console.log(element.fname);
                    });

                $('#id').val('');
            });
});
int id = Integer.parseInt(request.getParameter("number"));

    try{
    String query1   =   "select count(*) as total from Details where ID ='"+ 
    id +"'";
    ResultSet rs=st.executeQuery(query1);
    int ttl=0;
    if(rs.next())
    {               
        ttl=rs.getInt("total");
    }

    if(ttl<1){out.print("Record Does Not Exists");}
    else
    {
    String query2   =   "select * from Details where ID ='"+ id +"'";
    rs=st.executeQuery(query2);
    String fn,ln,m;
    while(rs.next())
    {               
        fn=rs.getString("FName");
        ln=rs.getString("LName");
        m=rs.getString("Contactno");

        JSONObject obj = new JSONObject();
        obj.put("fname",fn);
        obj.put("lname",ln);
        obj.put("mobile",m);
    }
    }

}
catch(SQLException se)
 {
   out.println("SQLException : "+se.getMessage());
 }

I have used this code but it is showing Uncaught SyntaxError: Unexpected end 
of JSON input
at Function.parse [as parseJSON] (<anonymous>) at line 
" var newdata = $.parseJSON(data); "
in jquery $.post() method