Relative Content

Tag Archive for jquery

Can REST, Ajax and jQuery work well together?

I’m trying to use REST (usign spring MVC) as my Ajax backend but got some problems when using it with jQuery. REST best pratices recommend using HTTP status code, e.g. 200, 403, 401, etc, and I have no problem with a 200 status code, jQuery’s ajax method have a done(data) callback that let me read the reponse in json format. But when I need to return some error in json format along with the status code, I got stucked. The fail(jqXHR, textStatus) callback doesn’t seem to support json in the response. So if I return JSON from the serverside, it will be put in jqXHR.reponseText and treated as plaintext instead.

Can REST, Ajax and jQuery work well together?

I’m trying to use REST (usign spring MVC) as my Ajax backend but got some problems when using it with jQuery. REST best pratices recommend using HTTP status code, e.g. 200, 403, 401, etc, and I have no problem with a 200 status code, jQuery’s ajax method have a done(data) callback that let me read the reponse in json format. But when I need to return some error in json format along with the status code, I got stucked. The fail(jqXHR, textStatus) callback doesn’t seem to support json in the response. So if I return JSON from the serverside, it will be put in jqXHR.reponseText and treated as plaintext instead.

Can REST, Ajax and jQuery work well together?

I’m trying to use REST (usign spring MVC) as my Ajax backend but got some problems when using it with jQuery. REST best pratices recommend using HTTP status code, e.g. 200, 403, 401, etc, and I have no problem with a 200 status code, jQuery’s ajax method have a done(data) callback that let me read the reponse in json format. But when I need to return some error in json format along with the status code, I got stucked. The fail(jqXHR, textStatus) callback doesn’t seem to support json in the response. So if I return JSON from the serverside, it will be put in jqXHR.reponseText and treated as plaintext instead.