ext--Ajax

4589 단어 ext
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>ajax.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <link rel="stylesheet" type="text/css" href="/web/ext/resources/css/ext-all.css" />
    <!-- GC -->
 	<!-- LIBS -->
 	<script type="text/javascript" src="/web/ext/adapter/ext/ext-base.js"></script>
 	<script type="text/javascript" src="/web/ext/adapter/ext/ext-all.js"></script>
 	<!-- ENDLIBS -->

    <script type="text/javascript" src="/web/ext/ext-all-debug.js"></script>
    <script type="text/javascript">
    	Ext.onReady(function(){
			Ext.Ajax.request({
			   url: 'time!getTime.action',
			   success: function(response, opts) {
			   	Ext.Msg.alert("success",response.responseText);
			      //var obj = Ext.decode(response.responseText);
			      //console.dir(obj);
			   },
			   failure: function(response, opts) {
			      //console.log('server-side failure with status code ' + response.status);
			      Ext.Msg.alert("failure",response.status);
			   },
			   params:{
			   	name:'test'
			   }
			});
			
			//  。
			var button = new Ext.Button(
				{
					text:" ",
					renderTo:document.body,
					handler:function(){
						Ext.Ajax.request(
							{
								form:'myform',
								params:'name'
							}
						);
					}
				}
			);		
			
			Ext.get("json").on("click",function(){
				Ext.Ajax.request(
					{
					 url:"time!getJson.action",
					 success:function(response,config){
					 	var json = Ext.util.JSON.decode(response.responseText);
					 	Ext.Msg.alert("","name="+json.name+",age="+json.age);
					 },
					 failure:function(response,config){
					 	Ext.Msg.alert(""," , !");
					 }
					}
				);
			});
			
			Ext.get('uploadBtn').on('click',function(){
				//var form = Ext.get('upload').dom;
				var form = document.forms[1];
				//alert(form==Ext.get('upload').dom);
				form.target = id; //  form iframe
				form.method = "post"; // post
				form.enctype = form.encoding = "multipart/form-data";
				var url = "time!doUpload.action"; //  。
				if(url) {
					form.action = url;
				}
				Ext.Ajax.request(
					{
						url:"time!doUpload.action",
						isUpload:true,
						form:"upload",
						success:function(response,cfg){
							var result = Ext.util.JSON.decode(response.responseText);
							Ext.Msg.alert("msg",result.msg);;
						},
						failure:function(response,cfg){
							var result = Ext.util.JSON.decode(response.responseText);
							Ext.Msg.alert("msg",result.msg);
						}	
					}
				);
			});
			
		
		});
	</script>
  </head>
  
  <body>
    	<form action="time!submitForm.action">
    		<input type="text" name="name" id="name">
    	</form>
    	
    	<input type="button" id="json" value="Json">
    	<div>
    		<span>Ajax </span><br>
	    	<form id="upload">
	    		<label> :</label>
	    		<input type="file" name="file">
	    		<br>
	    		<label> :</label>
	    		<textarea rows="4" cols="50" name="fileDesc"></textarea>
	    		<input type="button" value=" " id="uploadBtn">
	    	</form>
    	</div>
  </body>
</html>

좋은 웹페이지 즐겨찾기