2016-09-21 6 views
0

を働いていない:window.location.assignは、私は、サーバーにシリアライズされたフォームデータを送信し、次のAJAX POSTリクエストを持って

// Handle form submission. 
$('#evaluationform').on('submit', function(e){ 
    e.preventDefault(); 

    ajaxObject = { 
     url: $("#evaluationform").attr("action"), 
     type: 'POST', 
     dataType: 'json', 
     xhrFields: { 
      withCredentials: true 
     }, 
     crossDomain: true, 
     data: $("#evaluationform").serialize(), 
    }; 

    $.ajax(ajaxObject) 
     .success(function(data,status,xhr) { 
      window.location.assign("http://example.com/survey/instruction/thankyou.html"); 
     }) 
     .fail(function(data,status,xhr) { 
      window.location.assign("http://example.com/survey/instruction/fail.html"); 
     }) 
     .always(function(data,status,xhr) { 
      console.log(status); 
     }); 
}); 

割り当てパスはChromeとSafariで続いているものの、それがされFirefoxではありません。代入はFirefoxでは無視され、代わりに私のフォームのaction属性で定義されているAPI URLに私を吐き出します。

+0

潜在的なセキュリティ問題がここにあります:[ドキュメントをチェック](https://developer.mozilla.org/en-US/docs/Web/ API /ロケーション/割り当て)。 –

答えて

0

私はいつもこの構文を使用して、それが私の作品:window.location = 'http://www.somesite.com';

関連する問題