|
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> refreshing </title>
<Link href = "css/css.css" type = "text/css" rel = "stylesheet"/>
<Style type = "text/css">
Body {color: #555; font-size: 14px; padding: 0; margin: 0 ;}
# Form {background: # dedede; padding: 10px 20px; width: 300px ;}
# Show {background: # f6f6f6; padding: 10px 20px; width: 300px ;}
# Show p {margin: 6px; font-size: 13px; line-height: 22px; border-bottom: 1px dashed # cdcd ;}
</Style>
<Script type = "text/javascript" src = "jquery-1.7.2.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("# Sub"). click (function (){
// Just describe the principle, and then the steps for verifying the content of the text box are saved here, And the ajax request is sent directly.
$. Post ("deal. php ", {name: $ (" # name "). val (), content: $ ("# content "). val ()}, function (data ){
If (data. status ){
Var str = "<p> <strong>" + data. name + "</strong> published:" + data. content + "</p> ";
$ ("# Show"). prepend (str); // append the prefix
} Else {
Alert ("comment failed ");
}
}, 'Json ');
});
});
</Script>
</Head>
<Body>
<Div id = "form">
<Form action = "deal. php" method = "get" id = "suggest_form">
Username: <input type = "text" name = "name" id = "name"/> <br/>
Content: <textarea name = "content" id = "content"> </textarea> & nbsp;
<Input type = "button" value = "publish" id = "sub"/>
</Form>
</Div>
<Div id = "show">
<? Php
Include "config. php ";
$ SQL = "select * from test ;";
$ Res = mysql_query ($ SQL, $ link );
While ($ row = mysql_fetch_array ($ res )){
Echo "<p> <strong> ". $ row ['name']. "</strong> posted :". $ row ['content']. "</p> ";
}
?>
</Div>
</Body>
</Html> |