非同期通信なんですが前回はデータを取ってくるだけでしたが
今回はこちらからデータを投げて、その結果を取得して表示します。
ごちゃごちゃ言っててもしょうがないのでますはソース
<html>
<head>
<title>sample2</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script></head>
<body>
<script>
$(function() {
$('form#bar').submit(function(){
var postword = $("#text").val();
$.post(
'segmentationapi.php',
{
'word': postword,
'variation': '6'
},
function(data){
$('#message').html(data);
}
);
});
});
</script>
<form id="bar" name="bar" onsubmit="return false;">
<input type="text" name="text" id="text">
<input type="submit" value="send">
</form>
<div id="message"></div>
</body></html>
var post
word = $("#text").val(); $.post(
'segmentationapi.php',
{
'word': postword,
'variation': '6'
},
function(data){
$('#message').html(data);
}
);
onsubmit="return false;"
関連記事