[問題] 試著用ajax pose 資料到php
不管怎麼該都是傳送錯誤,翻了很多文都沒有用,想請各位大大幫我看看是哪裡錯了!!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文件</title>
</head>
<body>
</body>
</html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js
"></script>
<script type="text/javascript" src="http://simplesideias.com.br/media/ajax.js"
></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言板兒兒兒</title>
</head>
<body>
<font size="+6" color="#00CCFF" ><b>ya快來留言</b></font><br><br>
<form method="post" id="message_form" >
<!-- 以下是user送出表單內容-->
your name:
<input type="text" name="username" id="username" size="20" maxlength="20">
<br><br>
<textarea name="message" id="message" style="height:120px;width:400px"></t
extarea><br><br>
<input type="button" name="submit" id="submit" value=" 留言 " onClick="Che
ckIt();" >
<!------------->
</form>
<div id="result" ></div>
<SCRIPT type="text/javascript">
function CheckIt(){
// 檢查是否有符合留言條件
var username = $('#username').val();
var message = $('#message').val();
if ( username.length > 10 ) {
alert("Username 不可以超過十個字!");
return false;
}
else if ( message.length > 20 ) {
alert("Message 不可以超過二十個字!");
return false;
}
else {
alert("傳訊息囉!");
GOmessage();
};
} ;
</script>
<script type="text/javascript">
function GOmessage(){
var username = $('#username').val();
var message = $('#message').val();
/*
$.post('/textt.php',{Pusername:username,P
age},
function(data)
{
alert("you success!!!!");
},"text"
);
alert( "good!!!!" );
*/
$.ajax({
url:"textt.php",
data:'message=message&username=username',
type : "GET",
dataType:'text',
timeout:1000,
error:function (data){
$("#result").html(data);
alert("失敗");
},
success:function(){
alert("成功");
}
});
};
</SCRIPT>
</body>
</html>
手機排版請見諒~~
--
Sent from my Android
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.143.249.21
※ 文章網址: http://www.ptt.cc/bbs/Web_Design/M.1408388554.A.B9E.html
※ 編輯: hao520wxj (223.143.249.21), 08/19/2014 03:11:58
→
08/19 03:33, , 1F
08/19 03:33, 1F
→
08/19 03:33, , 2F
08/19 03:33, 2F
→
08/19 03:54, , 3F
08/19 03:54, 3F
→
08/19 03:54, , 4F
08/19 03:54, 4F
→
08/19 05:17, , 5F
08/19 05:17, 5F
→
08/19 05:17, , 6F
08/19 05:17, 6F
推
08/19 13:15, , 7F
08/19 13:15, 7F
推
08/19 14:25, , 8F
08/19 14:25, 8F
→
08/19 14:25, , 9F
08/19 14:25, 9F
→
08/19 16:32, , 10F
08/19 16:32, 10F
→
08/19 16:32, , 11F
08/19 16:32, 11F
推
08/19 19:28, , 12F
08/19 19:28, 12F
推
08/19 19:32, , 13F
08/19 19:32, 13F
→
08/20 00:39, , 14F
08/20 00:39, 14F
→
08/20 00:40, , 15F
08/20 00:40, 15F
→
08/20 00:40, , 16F
08/20 00:40, 16F
→
08/20 00:40, , 17F
08/20 00:40, 17F