ここに私の問題があります:私はindex.htmlにフォームを持っています。それにはテキスト入力があり、値はそれを処理して値を返すphpページへの$.postになります。私のコード:
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
<script>
function get(){
$.post('http://xxx/xxx/get.php', {name: form.name.value},
function(output){
$('#result').html(output).show();
});
}
</script>
</head>
<body>
<div data-role="page" id="header">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content">
<form name="form" id="form">
<input type="text" name="name"><input type="button" value="Get Output" onClick="get();">
</form>
<p> result here: </p>
<div id="result"></div>
</div>
<div data-role="footer">
<h4>Footer</h4>
</div>
</div>
</body>
</body>
</html>
とget.php
<?php
$name = $_POST['name'];
echo $name;
?>
これは、テスト目的の簡単なコーディングです。コードからわかるように、テキストフィールドに入力したテキストは get.php で処理されます。そこに echo $name を入れたので、名前は div id = result in index.html に表示されるべきです。コードは正しいと思いますが、うまくいきませんでした。ここで専門家の助けが必要です... 私は何を間違えましたか?