I have ajax request function
function Reject(id, scomment)
{
jQuery.ajax({
type: "POST",
url: "reject.php",
data: {id: id, Scomment: scomment},
cache: false,
success: function(response)
{
location.reload();
}
});
}
There is html from my php loop
<div class="modal-footer">
<textarea id="Scomment" name="Scomment" cols="40" rows="5" class="form-control"></textarea>
<button type="button" class="btn btn-danger" data-dismiss="modal" onClick="Reject('.$row['id'].', "sample text");">Reject</button>
<button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
</div>
So..
If i will use string.
onClick="Reject('.$row['id'].', "sample text");"
console returns Uncaught SyntaxError: Unexpected end of input
But..
If i will use any number instead of "sample text"
onClick="Reject('.$row['id'].', 262434);"
It works.
I am newbie and kindly please support me guys.
2
Answers
You just have to escape your double quotation, this error happens because the starting and ending quote will not match with the current implementation.
Like this:
Or use single quote instead.
You are using double quotes in double quotes. This leads to problem.
You can use single quotes in double quotes and viceversa like this