HTML:
<! Doctype HTML>
<HTML lang = "ZH-CN">
<Head>
<Meta charset = "UTF-8">
<SCRIPT type = "text/JavaScript" src = "JS/jquery-1.11.0.min.js"> </SCRIPT>
<SCRIPT>
$ (Document). Ready (function (){
$ (Document). On ("click", "# Send", function (){
$. Get ("get1.php ",{
Username: $ ("# username"). Val (),
Content: $ ("# Content"). Val ()
}, Function (result ){
$ ("# Content"). Val (result );
});
});
});
// $ (Function (){
// $ ("Send"). Click (function (){
// $. Get ("get1.php ",{
// Username: $ ("# username"). Val (),
// Content: $ ("# Content"). Val ()
//}, Function (data, textstatus ){
// $ ("# Restext" 2.16.html (data );
//});
//});
//});
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" Action = "#">
<P>
Comment:
</P>
<P>
Name:
<Input type = "text" name = "username" id = "username"/>
</P>
<P>
Content:
<Textarea name = "content" id = "content" rows = "2" Cols = "20">
</Textarea>
</P>
<P>
<Input type = "button" id = "send" value = "Submit"/>
</P>
</Form>
<Div class = "comment">
Existing comments:
</Div>
<Div id = "restext"> </div>
</Body>
</Html>
Get1.php:
<? PHP
// Echo "123 ";
$ Username = $ _ Get ['username'];
If ($ username = "Bingbing "){
Echo "Good Guys ";
} Else {
Echo "bad guys ";
}
// $ Arr = array ('title' => "2014 ranking list", 'data' => array ('id' => 1, 'name' => 'ice id '));
// Echo json_encode ($ ARR );
?>
[Technology] Ajax $. Get ()