在PHP SOAP的Web服務的操作在我的PHP Web服務,我有一個函數:呼叫於Android的PhoneGap
function create_promo($codeBarre, $designation, $dateDebut, $dateFin, $prix, $TVA)
{
$db = new PDO('mysql:host=localhost;dbname=phone', 'root', '');
$req = $db->prepare("insert into promotion
values
(:codeBarre, :designation, :dateDebut, :dateFin, :prix, :TVA)");
$req->execute(array(':codeBarre'=>$codeBarre, ':designation'=>$designation,
':dateDebut'=>date("Y-m-d", strtotime($dateDebut)),
':dateFin'=>date("Y-m-d", strtotime($dateFin)),
':prix'=>$prix, ':TVA'=>$TVA));
return "promotion créer";
}
此功能是在C:\ WAMP \ WWW。
創建我的科爾多瓦項目,我寫這篇文章的代碼:
<script type="text/javascript" src="js/jquery.js"></script>
<title>Hello World</title>
<script type="text/javascript">
$(document).ready(function() {
$("#Ajouter").click(function() {
var codeBarre = $("#codeBarre").val();
var designation = $("#designation").val();
var dateDebut = $("#dateDebut").val();
var dateFin = $("#dateFin").val();
var prix = $("#prix").val();
var TVA = $("#TVA").val();
var dataString = "codeBarre=" + codeBarre + "&designation=" + designation + "&dateDebut=" + dateDebut + "&dateFin=" + dateFin + "&prix=" + prix + "&TVA=" + TVA + "&Ajouter=";
$.ajax({
url:"https://192.168.1.12/testphone/server.php//create_promo",
type:"POST",
data:dataString,
crossDomain:true,
cache:false,
beforeSend: function(){ $("#insert").val('Connecting...');},
success: function(data){
if (data=="ok")
{
alert("inserted");
$("#Ajouter").val('submit');
}
else if (data=="error")
{
alert("error");
}
}
});
return false;
});
});
</script>
</head>
<body>
<!--<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>-->
<form method="post">
<table>
<tr>
<td>Code Barre:</td>
<td> <input type="text" id="codeBarre"></td>
</tr>
<tr>
<td>Designation:</td>
<td> <input type="text" id="designation"></td>
</tr>
<tr>
<td>Date Debut:</td>
<td> <input type="date" id="dateDebut"></td>
</tr>
<tr>
<td>Date fin:</td>
<td><input type="date" id="dateFin"></td>
</tr>
<tr>
<td>Prix:</td>
<td> <input type="number" id="prix" step="any"></td>
</tr>
<tr>
<td>TVA:</td>
<td> <input type="number" id="TVA"></td>
</tr>
<tr>
<td> <input type="button" id="Ajouter" value="Ajouter"></td>
</tr>
</table>
</form>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
的科爾多瓦項目是在C:目錄。 警告消息不顯示;我如何顯示錯誤?
你測試瀏覽器的代碼? –
不,我在模擬器中測試 – user1674906