Ext.Ajax.request and Formpanel.getform (). Submit () __ajax

Source: Internet
Author: User
Formpanel Submission Method
Ext.MessageBox.wait (' The data is being submitted, please wait a moment ... ', ' hint ');
Xxxxformpanel.getform (). Submit ({
	timeout:60,
	success:function (form, action) {
        //Business Success
		Ext.MessageBox.updateProgress (1);
		Ext.MessageBox.hide ();

	},
	failure:function (form, action) {
        //Business failure
		Ext.MessageBox.updateProgress ( 1);
		Ext.MessageBox.hide ();

		Switch (action.failuretype) {case
			Ext.form.Action.CLIENT_INVALID:
				Ext.Msg.alert (' ERROR. ', ' There is no validated data! ';
				break;
			Case Ext.form.Action.CONNECT_FAILURE:
				Ext.Msg.alert (' ERROR. ', ' connection Error! ');
				break;
			Case Ext.form.Action.SERVER_INVALID:
				Ext.Msg.alert (' Error! ', action.result.msg);
		}
	}
);


How to submit Ajax
	Ext.Ajax.request ({
		URL: ...,
		params: {
			...
		},
		success:function (response, opts) {
			var o = Ext. Util. Json.decode (response.responsetext);
			if (o.success) {
				//Business execution Success
			} else{
				//Business execution Failure
			}
		,
		failure:function (response, opts) {
			//? What to do here, you can say  : oops: 
		}
	);


Both can receive the following JSON string returned by the server side:
{success:true/false,msg: ' xxxx '}


If success is true, the program enters the success callback function for the Formpanel submission, and the program enters the success callback function for the Ajax submission method.
The difference is that if success is false, the program enters the failure callback function for the Formpanel submission, and the Ajax submission way, the program still enters the success callback function.

Summarize:
Success true and false can be used to indicate the success or failure of the business.
1, in the Formpanel submission mode, the successful operation in the success callback function, after the failure of the operation in the failure callback function;
2. In the Ajax submission method, the success of the business failure should be done in the success callback function, and true or false to o.success (see Code and comments).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.