ExtJS 4 Mock Response for File Upload

I’ve found it very helpful when working with Ext JS to build a mock application so that I can easily play with the UI. Usually I load data for grids and forms and such by having the url go to a file (I usually put a .json extension) that is a JSON object with the fields I need.

I did this for a form submit that includes a file upload field. In this case the submit becomes a mulitpart POST request. The reponse to the client needs to have a content-type of text/html. The mock responses never have a content-type set. Instead, I made the mock response file look like this:

	"success" : true,
	"message" : "Email successfully sent"

This is good enough for Ext JS to properly handle the response for a request like this:

			var emailForm = emailPanel.getForm();
			if ( emailForm.isValid() ) {
					url: './mymockapp/emailresponse.json',
					scope: this,
					success: this.onEmailResponse,
					failure: this.onEmailResponse


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s