javascript - JSON parse error on comments system -


I am currently working on a comment system, all this was working fine yesterday, today I started the errors was doing. I am using json to post a comment without reloading a page. The error I am getting is "Syntax Error: Jason. Piece: Unexpected Character". To show me I have to reload the page for comment.

In addition, when I was working on this, I could not understand how to insert the date, it comes from the database when it loads from the page. It was being shown before the page was reloaded.

Here is the code:

  $ (document) .ready (function () {// This will fire the page completely $ ('#' -Post-BTN ') is loaded. Click (function () {comment_post_btn_click ();});}); The function is entered in comment_post_btn_click () {// textarea, the person who has entered var_comment = $ ('# comment-post-text'). Val (); Var _userId = $ ('# userId'). Val (); Var _userName = $ ('#username'). Val (); Var _PlaceId = $ ('# PlaceId'). Val (); Var _date = $ ('date'). Val (); If (_comment.length & gt; 0 & amp; amp; _userId! = Null) {// Proceed with our AJAX callback $ ('comment-insert-container'). CSS ('border', '1px solid # e1e1e1'); $ .post ("ajax / comment_insert.php", {task: "comment_insert", userId: _userId, comment: _comment, PlaceId: _PlaceId, date: _date}) .error (function () {console.log ("Error: ");). Svitt (function) {// Success // Work: Insert HTML in commentary_internet (jQuery.parseJSON (data)); console.log (" responseText: "+ data);}) ; Console.log (_comment + "Username:" + _userName + "User ID:" + _userId + "PlaceID:" + + _PlaceId + "Date:" + _date); } And {$ ('comment-insert-container'). CSS ('border', '1px solid #ff0000'); Console.log ("The text field was empty"); } // text field removes the text from $ ('# comment-post-text'). val (""); } Function comment_insert (data) {var t = ''; T + = '& lt; Li class = "comment-holder" id = "_'+ data.comment.comment_id + '" & gt;'; T + = '& lt; Div class = "user-img" & gt; '; T + = '& lt; Img src = "'+ data.user.profile_img +'" class = "user-img-pic" / & gt; '; t + = '& lt; / Div & gt; '; T + = '& lt; Div class = "comment-body" & gt; '; T + = '& lt; h3 class = "user name-area" & gt; + data.user.userName + '& lt; / H3 & gt; '; T + = '& lt; p class = "date" & gt; + data.comment.date + '& lt; / P & gt; '; T + = '& lt; / Div & gt; '; T + = '& lt; Div class = "comment-text" & gt; + data.comment.comment + '& lt; / Div & gt; '; T + = '& lt; div class = "comment-button-holder"> gt; t + = '& lt; Ul & gt; '; T + = '& lt; Li id = "'+ data.comment.comment_id +' class =" delete-btn "& gt; X  '; t + ='  Increase ('t. container-ul'); t + = '& lt; / div & gt;'; t + = '& lt; / li & gt;'; $ ('.not comments-holder-ul'). Add_delete_handlers ();}    

Whatever ajax / comment_insert.php does not return valid JSON Use to check syntax.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -