I’m attempting to do some AJAX using jQuery but I seem to be having an issue.
In my Safari inspector, I’m getting Semantic Issue and Unexpected Token :.
Am I just being stupid? It seems to be happening on my data: line of the $.ajax function:
function storeEmail ()
{
alert('Entered Function');
email = $('#emailField').val();
$('#emailField').hide();
console.log('Yep: '+email);
if(email.indexOf('@'))
{
$.ajax(function(){
url: "emailer/storeEmail.ajax.php",
type: "POST",
data: { "email" : email }
}).done(function(data){
if(data.resp == "success")
$('#emailSuccess').show();
else
{
$('#failedText').html('Error: '+data.resp);
$('#emailFailed').show();
}
});
}
else
{
$('#failedText').html('Error: Email is invalid!');
$('#emailFailed').show();
}
return false;
}
You appear to be passing a function to
$.ajax(). I think you meant to pass an object. Remove thefunction()piece and you should be good to go.