-1

Intel XDK を使用して HTML5 モバイル アプリを構築しようとしています。何らかの理由で、Intel XDK でエミュレートすると動作しますが、実際のデバイスで試してみるとエラー アラートが表示されます。

http://localhost次のエラーが発生しました: {"readyState":0,"responseText":"","status":0,"statusText":"error"}

request = $.ajax({
                    url: "http://domain.com/form.php",
                    type: "post",
                    data: serializedData
                });

                // callback handler that will be called on success
                request.done(function (response, textStatus, jqXHR){
//do stuff
                });

                // callback handler that will be called on failure
                request.fail(function (jqXHR, textStatus, errorThrown){
                    // log the error to the console
                    alert(
                        "The following error occured: "+
                        JSON.stringify(jqXHR,textStatus,errorThrown)
                    );
                });
4

1 に答える 1

0

クロスオリジン要求が原因で失敗している可能性があります。Intel XDK アプリのクロスオリジン エラーを回避するには、これらのスクリプト タグを追加する必要があります。

<script src="intelxdk.js"></script>
<script src="xhr.js"></script>

実際のスクリプト ファイルは必要ありません。上記のスクリプト タグを追加するだけindex.htmlで、インテル XDK ビルドに自動的に含まれます。詳細はこちら。

于 2014-03-26T13:37:55.013 に答える