I've been trying out the jquery form plugin and it works wonderfully. Oh, except for IE8. It's always ie8.
Anyways, on the success response callback, ie8 prompts me to download the response instead of actually calling the success function.
Here is what my javascript code looks like
$("#form1").ajaxForm({
url: "http://localhost:4887/api/file/POST",
type: "POST",
success: function (data)
{
//response stuff here
}
});
I've tried specifying the datatype for the ajax form, but woe is me, it didn't work
The only thing I am returning from the server is just a string. Once again, IE8 prompts me to download this string instead of just calling the success function. After some research, I understand that I might have to modify the http headers? Could anyone shed some light on this? Or give another way of going about this?
UPDATE Here is a brief look at the C# controller
public class fileController : ApiController
{
public JsonResult POST()
{
HttpPostedFile file = null;
string encodedString = //do stuff here to get the base64 string
ModelName obj = new ModelName();
obj.characters = encodedString;
JsonResult result = new JsonResult();
result.Data = obj;
result.ContentType = "text/html";
return result;
}
Request Headers...
Accept application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /
Accept-Language en-US
User-Agent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 1.1.4322)
Content-Type multipart/form-data; boundary=---------------------------7dd3e622907b6
Accept-Encoding gzip, deflate
Proxy-Connection Keep-Alive
Content-Length 300
Response Headers HTTP/1.1 200 OK Cache-Control no-cache
Pragma no-cache
Content-Type application/json; charset=utf-8
Expires -1
Server Microsoft-IIS/8.0
X-AspNet-Version 4.0.30319 X-Powered-By ASP.NET