わかりました。AJAXは確かに弱いエリアなので、私は頭の中にいます。私は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')をクリックします(関数(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;
});
誰かがコードをチェックアウトし、何を参照することができますIまた、ライブを見るには、this link
さえJSONと?心に留めておくと、私はexpがゼロです。 with ajax/json :) - 愚かな質問のお詫び –
また、ページリフレッシュではなく、上記のコードを使用してエラーメッセージが表示されるはずですか? –
返されるタイプに関係なく、このようなクロスサイトリクエストはできません。あなたが周りを検索して回避策を見つけることができますが、私が言うように、制限は良い理由のためにそこにあります。 –