안녕하세요 여러분과 고맙습니다. PhoneGap 2.1.0을 사용하고 있습니다.Ajax 게시물이 작동하지 않습니다. - Jquery Phonegap Android
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 파일이 같은 디버그 이유로 그냥 : 화이트리스트 다에서 는
**<access uri="*" subdomains="true" />
<access origin=".*" subdomains="true"/>**
내가 내 대학 웹 서버에서 원격 PHP 파일을 호출하는이 기능을 사용하고 있습니다 .. 허용됩니다 :
01 :<?php
header('Content-Type: application/json');
$sample = array(
'name'=>'My Name',
'email'=>'[email protected]'
);
echo json_encode($sample);
?>
그러나 아약스 요청은 내가 제출을 클릭하면이 오류가 계속 이클립스 .. 일이되지 않는다
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>
나는 거의 모든 웹 생각은 ... 이일은 ... 모든 것이 많이 고맙습니다 .. 을 테스트되었습니다들을 검색.
'http : // -/smartphone/login.php'이 유효한 URL입니까? 그것은 나처럼 보이지 않습니다. –
- mydomain.example.com과 같은 도메인 ..을 나타냅니다. 오해 된 경우 사과드립니다. – gnnpls
PHP 측에서 "Access-Control-Allow-Origin : *"HTTP 헤더를 추가하여 작동하는지 확인하십시오. – onon15