Showing posts from July, 2009

Returning content type of 'application/json' using jQuery ajax form

Ajax form in the jQuery is a wonderful feature for the developers as it allows multi-part upload without refreshing the page. Ajax form call creates a iframe which is invisible and then submits the form from with in iframe. Browser checks for the content type of the returned content and verifies whether it can handle or not before passing content to the iframe. If the response content type is appliction/json, the browser donot know how to handle the content and opens popup to save the content instead of handling to the iframe, the source of the request. So basically, ajax form of jQuery cannot be used for api calls returning content type of application/json which is a major issue while working with REST API calls that accepts multi-part/formdata requests and return content of type application/json. Alternatives : Return content of type application/xml and parse the same on the client side. Use servelts to handle the multi-part request and return json string form of the object you wis