1 <Headrunat= "Server">2 <title>The $.get () method in jquery</title>3 <Scriptsrc= "Scripts/jquery-1.4.1.min.js"type= "Text/javascript"></Script>4 <Scripttype= "Text/javascript">5 $(function () {6 $("#send"). Click (function () {7 $.get (8 "get.aspx", //URL9 {username: $ ("#username"). Val (),Ten content: $ ("#content"). Val () One }, //Data A function(data, textstatus) { - $("#resText"). HTML (data); - the } //callback function - ) - }); - }); + </Script> - </Head> + <Body> A <formID= "Form1"runat= "Server"style= "border:1px solid grey; width:300px;"> at <Div> - <P> -Comments:</P> - <P> -Name:<inputtype= "text"name= "username"ID= "username" /></P> - <P> inContent:<textareaname= "Content"ID= "Content"rows= "2"cols= " the"></textarea></P> - <P> to <inputtype= "button"ID= "Send"value= "Submit" /></P> + </Div> - <Divclass= "comment"> the comments already available: * <DivID= "ResText"> $ </Div>Panax Notoginseng </Div> - </form> the </Body>
View Code
1 Public Partial class Get: System.Web.UI.Page2 {3 protected voidPage_Load (Objectsender, EventArgs e)4 {5 stringusername=request.querystring["username"];6 stringContent = request.querystring["content"];7 8 //format of the server return content: Html,xml,script,json,text, and _default9 //the HTML format is used hereTen stringBackcontent ="<p> Name:"+username+"<br/> Content:"+content+"</p>"; One Response.Write (backcontent); A } -}
View Code
:
Ajax Learning Notes (3)--$.get () method