JavaScript DHTML/Ext JS/Form Submit — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 07:21, 26 мая 2010

Form submit failure event

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                    Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>



Form submit failure type: Ext.form.Action.CONNECT_FAILURE

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                    Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>



Form submit failure type: Ext.form.Action.SERVER_INVALID

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                    Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>



Form submit success event

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                   Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>



Get error message for a form submit

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                    Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>



Get result status text for a form submit

   
<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

    var myform = new Ext.FormPanel({ 
      url: "your.php",
      renderTo: Ext.getBody(),
      frame: true,
      title: "Title",
      width: 250,
      items: [
                {
            xtype: "textfield",
            fieldLabel: "Title",
            name: "title",
            allowBlank: false
            }
        ],
            buttons: [
                {
            text: "Save",
            handler: function(){
                        myform.getForm().submit({
                            success: function(f,a){
                                Ext.Msg.alert("Success", "It worked");
                            },
                            failure: function(f,a){
                                if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
                                
                                    Ext.Msg.alert("Failure", "Server reported:"+a.response.status+" "+a.response.statusText);
                                }
                                if (a.failureType === Ext.form.Action.SERVER_INVALID){
                                    Ext.Msg.alert("Warning", a.result.errormsg);
                                }
                            }
                        });
            }
          }, 
          {
            text: "Reset",
            handler: function(){
              myform.getForm().reset();
            }
          }
      ]
    });

});
</script> 
<div id="div1">asdf</div>
</body>
</html>