Would like to ask for a help regarding on ajax's success part. I tried to log it on the console but there is this kind of error
Uncaught SyntaxError: Unexpected number in JSON at position 4
at JSON.parse (<anonymous>)
at Function.parseJSON (jquery.min.js:4)
at Object.success (cta:378)
at c (jquery.min.js:4)
at Object.fireWith [as resolveWith] (jquery.min.js:4)
at k (jquery.min.js:6)
at XMLHttpRequest.r (jquery.min.js:6)
Maybe there's something I didn't understand on my code. Here is my code
<script>
$(document).ready(function() {
$(".submit").click(function() {
var emailval = $("#email").val().trim();
$.ajax({
url: '/test.php',
type: 'POST',
dataType: 'json',
data: 'email='+emailval,
success: function(data) {
var result = $.parseJSON(data);
console.log(result);
}
});
});
});
</script>
I wanted to get the value of the email and transfer it to my PHP file. Please help
</div>