0

問題:フォームが存在するページURLとは異なるフォームaction="url"を持つフォームがあります。

ページURL=www.page.com
フォームアクション=" http://www.differentserver.com "

問題:フォームを投稿すると、フォームのアクションURLに移動します。

質問:アクションURLにPOSTし、jquery/ajaxを使用してフォームページにとどまるための最良の方法は何ですか

また、アクションURLは、リードが通過したかどうかを示すxmlをポストバックします。

4

4 に答える 4

2

You cannot use AJAX to submit data to another domain.

However you can use an old "hack":

<form action="http://www.differentserver.com/" method="post" target="hiddeniframe">
    ...
</form>
<iframe style="display:none" name="hiddeniframe"></iframe>

This will submit the form to the other domain, but won't appear to affect the current document.

于 2013-03-06T22:24:16.030 に答える
1

You can always post it to a hidden Iframe target='framename' and hook into the Iframe's ONLOAD event to detect when it is complete.

于 2013-03-06T22:23:43.240 に答える
0

Jqueryはこれをうまく行います

フォーム全体を投稿する

//Jquery Code
$.post("test.php", $("#form_name").serialize(), function(result){
 // return 
 var aa = result;

});

フォームの特定の部分を投稿する

//Jquery Code
 /* get some values from elements on the page: */
 var $form = $( this ),
  term = $form.find( 'input[name="s"]' ).val(),
  url = $form.attr( 'action' );

 /* Send the data using post */
 var posting = $.post( url, { s: term } );

 /* Put the results in a div */
 posting.done(function( data ) {
   var content = $( data ).find( '#content' );
  $( "#result" ).empty().append( content );
   });

[送信]ボタンを使用している場合、これによりフォームが正常に投稿されなくなります。

 /* stop form from submitting normally */
  event.preventDefault();
于 2013-03-06T22:36:17.957 に答える
0

Redirect after the differentserver.com OR use curl to perform the action

于 2013-03-06T22:23:44.290 に答える