みなさん、こんにちは。よろしくお願いします。Phonegap2.1.0を使用しています。ホワイトリストでは、すべてが受け入れられます。
**<access uri="*" subdomains="true" />
<access origin=".*" subdomains="true"/>**
この関数を使用して、大学のWebサーバーからリモートのphpファイルを呼び出しています。
var postData = $(this).serialize();
$.ajax({
type: 'POST',
url: 'http://--/smartphone/login.php',
dataType : 'json',
data: postData,
success: function(data){
alert("good");
},
error: function(){
alert('problem!');
}
});
phpファイルは、次のようなデバッグ上の理由によるものです。
<?php
header('Content-Type: application/json');
$sample = array(
'name'=>'My Name',
'email'=>'my_email@example.com'
);
echo json_encode($sample);
?>
しかし、ajaxリクエストは発生していません。Eclipseでは、[送信]をクリックするとこのエラーが発生し続けます。
JSCallback Error: Request failed with status 0 at file:///android_asset/www/js/cordova-2.1.0.js:3743
さらに、追加するのを忘れたのは、エミュレータからのリンクとしてURLを開くことができるということです。これは正常に機能します。
* htmlコード: *
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" charset="utf-8" src="js/cordova-2.1.0.js"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<title>Smart Greenhouse</title>
</head>
<body>
<div id="container">
<img src="css/images/smart_green_house.png" class="logo" alt="l1ogo" />
<form id="login_form" class="first_display" >
<label class="title"> E-mail:</label>
<input id="1" type="email" class="input" size="45" name="email" />
<label class="title"> password:</label>
<input id="2" type="password" class="input" size="45" name="password" />
<input id="3" class="submit_type" type="submit" value="login" />
</form>
</div>
</body>
</html>
私は検索しました私はほとんどウェブ全体だと思います...2日間の検索...すべてがテストされました..どうもありがとう..