AJAX 範例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>HIV REVIEW System</TITLE>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title> ref </title>
<link rel="stylesheet" type="text/css" href="kktext.css" media="screen" />
<! ------- must care the path --------------------------------------------!>
<script type="text/javascript" src="./js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="./js/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"> </script>
<! --we can check using the google crome debug tools -------------------------!>
<script type="text/javascript">
function nothing() {
alert("查無任何資料,請重新查詢");
window.location.href = "..\\1090.php";
}
</script>
$(document).ready(function () {
$('#btn').click(function (){
$.ajax({
url: 'hello.php',
cache: false,
dataType: 'html',
type:'GET',
data: { name: $('#name').val()},
error: function(xhr) {
alert('Ajax request 發生錯誤');
},
success: function(response) {
$('#msg').html(response);
$('#msg').fadeIn();}
});
});
$('#clean').click(function(){
$('#msg').html("");
// document.getElementById('msg').innerHTML = "";
});
function btnAjax(para,row) {
$.ajax({
type: "post",
url: "db1092.php?hosp_id="+para,
dataType:"text",
async: false,
cache: false,
contentType: "application/json; charset=big5",
success: function(response) {
response = "Data Saved!"
alert(response);
$("#msg").css({'color':'red','font-size':'40px'});
$(btnConRow).attr( "disabled",true );
}
});
}
</head>
<Body>
<input type ="button" value="submit" onClick="nothing"></input> <br>
<div id='msg' style="text-align:center;font-size:20px;">
</div>
</Body>
</html>
留言列表