I am have a problem with the following Uncaught SyntaxError: Unexpected token Error after switching from an input box to textarea. This error occurs when trying to delete the text entered into the textarea after submitting it.
textarea:
<textarea name="chatter"></textarea> Function call:
<a href='javascript:void(0);' onClick='deletecmnt(this, '".$val['id']."', '".BASE_URL."');' title='Delete Chatter'>X</a>; delete function:
function deletecmnt(obj, cmt_id, baseurl){ var lg_chk = loginchk(); if(lg_chk){ var object = $(obj).parent().parent(); $.ajax({ type: "GET", // error: function(error){console.log("Error:");console.log(error);}, url:baseurl+'deletechatter.php?id='+cmt_id, dataType:'json', success:function(response){ object.remove(); } }); } else location.href=baseurl; } Ok so inside Chrome I receive the error stated above but in Firefox I receive the following:
SyntaxError: syntax error deletecmnt(this, However, I don't see anything wrong with it and it worked when I was using a input box. I even switched it back and it worked so what is it about the textarea that it does like? Please let me know what I am doing wrong.
Here is what I got so far:
<a data-id='".$val['id']."' data-base-url='".BASE_URL."' href='javascript:void(0);' title='Delete Chatter'>x</a> <script>$("a[title='Delete Chatter']").on('click', deletecmnt);</script> function deletecmnt(obj, cmt_id, baseurl){ var lg_chk = loginchk(); if(lg_chk){ var object = $(this).parent().parent(); $.ajax({ type: "GET", // error: function(error){console.log("Error:");console.log(error);}, url:baseurl+'deletechatter.php?id='+cmt_id, dataType:'json', success:function(response){ object.remove(); } }); } else location.href=baseurl; }