Хорошо, я нахожусь над своей головой, поскольку AJAX - определенно слабая область. У меня есть страница, которая должна отправить форму регистрации через ajax в другой домен, чтобы обработать ее, а затем вернуться с сообщением об успехе / неудаче.
При использовании следующего кода страница просто обновляется и ничего не отправляется?
Код формы:
<form method="post" onSubmit="return submitGetApp();" class="kinkast_signup">
<input id="login_email" type="text" name="to" />
<input id="signInButtonSubmit" type="submit" name="action" value="Send" />
</form>
Код jQuery:
$ ('# signInButtonSubmit'). click (function (e) {
//Get the data from all the fields
var number = $('input[name=to]');
//Simple validation to make sure user entered something
//If error found, add hightlight class to the text field
if (number.val()=='') {
name.addClass('hightlight');
return false;
} else name.removeClass('hightlight');
//organize the data properly
var data = 'number=' + number.val();
//show the loading sign
$('p.ajax_message').hide();
//start the ajax
$.ajax({
//this is the php file that processes the data and send mail
url: "http://video.kinkast.com/getapp",
//GET method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function () {
$('p.ajax_message').html('Success!');
alert('Worked!');
},
//Failure
error: function(xhr, status, e) {
alert(status, e);
}
});
//cancel the submit button default behaviours
return false;
});
Может кто-нибудь проверить код и посмотреть, что мне не хватает? Кроме того, чтобы увидеть его в прямом эфире, посетите эту ссылку