It should not be our task to format your code. It is a general and important task for a developer who wants (and must) debug his/her own code.
Code:
$(document).ready(function() {
$('#formId').submit(function() {
$.ajax({
type: 'POST',
url: 'http://www.eshop-bazar.com/market/',
data: '$('#formId').serialize()',
success: 'function(data, textStatus, jqXHR) {
'{e.preventDefault();
alert('Added to Your cart, please continue');
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
return false;
});
});
What do we see now?
- Single quotes inside single quotes must be escaped as
\'. But you must not have single quotes around Javascript statements. Otherwise they won't be statements any more
- There is an extra single quote before the function keyword in the success method
- There is an extra single quote and opening bracket inside the success method (before e.preventDefault())
- It doesn't make any sense to have e.preventDefault inside the success method. At that point of time the .submit() handler already finished
Try this
Code:
$(document).ready(function() {
$('#formId').submit(function(e) {
$.ajax({
type: 'POST',
url: 'http://www.eshop-bazar.com/market/',
data: $("#formId").serialize(),
success: function(data, textStatus, jqXHR) {
alert('Added to Your cart, please continue');
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
e.preventDefault();
return false;
});
});