i am trying to use ajax in one of JavaScripts to send an email form WebSite. But it is not working. I simplified ajax code as much as i can but still it is not working it is like web is totally ignoring this ajax script.
JS/JQuery code
<script>
function sendMail() {
$.ajax({
url: 'http://us13.api.mailchimp.com/3.0/',
success: function (response) {
alert(response);
}
});
};
</script>
and Html code is classic button:
<button type="submit" onclick="sendMail()">Use AJAX</button>
Is there something wrong?
EDIT I tried both ways as u said (change type to button and also with prevent to submit) but still same problem now code looks like this:
<button type="button" onclick="sendMail()">Use AJAX</button>
<script>
function sendMail() {
alert("test");
$.ajax({
url: 'http://us13.api.mailchimp.com/3.0/',
success: function (response) {
alert(response);
}
});
}
alert("test") is executed properly but ajax is still ignored