I have a FormPanel which is used to upload a file along with several other fields. In my FormPanel I have fileUpload set to true, and I have the following submit handler:
Code:
submitHandler: function () {
if (this.getForm().isValid()) {
this.getForm().submit({
url: baseUrl + '/TestRequests/AddRequest',
//waitMsg: 'Adding Request',
success: function (form, o) {
this.fireEvent(EventStrings.EditRequestSaved);
},
failure: function (form, o) {
Ext.Msg.show({
title: 'Add Request Failed',
msg: o.result.error,
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR
});
}
});
}
}
When I click on the save button, chrome's js console shows "Uncaught SyntaxError: Unexpected token <" in ext-all-debug.js on line 4233.
The Json the AddRequest URL returns is:
Code:
{"success":false,"msg":"Failed to add request"}
There is no other content being transferred from the server to the web browser. No matter what json gets returned though (even if a 404 occurs) the syntax error still happens.
When I step into the code, into the doDecode function and look at what is being passed into the json parameter, Chrome's console shows the parameter as being equal to:
Code:
<pre style="word-wrap: break-word; white-space: pre-wrap;">{"success":false,"msg":"Failed to add request"}</pre>
Since doDecode is trying to eval() this string I can see why the syntax error is occurring, but I don't understand why that is happening in the first place.
One thing I noticed is that the chrome console also shows this warning message:
Code:
Resource interpreted as document but transferred with MIME type application/json.
The only thing I can think of is that submitting this form is triggering something that is making the browser thing a document is being returned when it is really json that is being returned. There are 2 other AJAX calls that run before this (loading of data into 2 ext grids) and those are being correctly recognized by Ext as json, and the headers for the AddRequest response are correct, and correctly declaring the response as json as far as I can tell. The response headers are:
Code:
Cache-Control:private
Content-Length:47
Content-Type:application/json; charset=utf-8
Date:Tue, 04 Jan 2011 18:26:40 GMT
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:2.0
X-Powered-By:ASP.NET
Does anyone have any idea why this is happening?