POST JSON fails with 415 Unsupported media type, Spring 3 mvc

I’ve had this happen before with Spring @ResponseBody and it was because there was no accept header sent with the request. Accept header can be a pain to set with jQuery, but this worked for me source $.postJSON = function(url, data, callback) { return jQuery.ajax({ headers: { ‘Accept’: ‘application/json’, ‘Content-Type’: ‘application/json’ }, ‘type’: ‘POST’, ‘url’: … Read more

jQuery.ajax handling continue responses: “success:” vs “.done”?

success has been the traditional name of the success callback in jQuery, defined as an option in the ajax call. However, since the implementation of $.Deferreds and more sophisticated callbacks, done is the preferred way to implement success callbacks, as it can be called on any deferred. For example, success: $.ajax({ url: “https://stackoverflow.com/”, success: function(data) … Read more

Request Monitoring in Chrome

I know this is an old thread but I thought I would chime in. Chrome currently has a solution built in. Use CTRL+SHIFT+I (or navigate to Current Page Control > Developer > Developer Tools. In the newer versions of Chrome, click the Wrench icon > Tools > Developer Tools.) to enable the Developer Tools. From … Read more

jQuery: Performing synchronous AJAX requests

As you’re making a synchronous request, that should be function getRemote() { return $.ajax({ type: “GET”, url: remote_url, async: false }).responseText; } Example – http://api.jquery.com/jQuery.ajax/#example-3 PLEASE NOTE: Setting async property to false is deprecated and in the process of being removed (link). Many browsers including Firefox and Chrome have already started to print a warning … Read more

UIForm with prependId=”false” breaks

Indeed, UIComponent#findComponent() as done by <f:ajax render> fails when using <h:form prependId=”false”>. This problem is known and is a “Won’t fix”: JSF spec issue 573. In my humble opinion, they should never have added the prependId attribute to the UIForm during the JSF 1.2 ages. It was merely done to keep j_security_check users happy who … Read more

How can I post data as form data instead of a request payload?

The following line needs to be added to the $http object that is passed: headers: {‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’} And the data passed should be converted to a URL-encoded string: > $.param({fkey: “key”}) ‘fkey=key’ So you have something like: $http({ method: ‘POST’, url: url, data: $.param({fkey: “key”}), headers: {‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’} }) From: https://groups.google.com/forum/#!msg/angular/5nAedJ1LyO0/4Vj_72EZcDsJ UPDATE To … Read more

Basic example of using .ajax() with JSONP?

JSONP is really a simply trick to overcome XMLHttpRequest same domain policy. (As you know one cannot send AJAX (XMLHttpRequest) request to a different domain.) So – instead of using XMLHttpRequest we have to use script HTMLl tags, the ones you usually use to load JS files, in order for JS to get data from … Read more

CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

This is a part of security, you cannot do that. If you want to allow credentials then your Access-Control-Allow-Origin must not use *. You will have to specify the exact protocol + domain + port. For reference see these questions : Access-Control-Allow-Origin wildcard subdomains, ports and protocols Cross Origin Resource Sharing with Credentials Besides * … Read more