开发者

Standard Ajax/json library or framework?

I use jQuery's ajax function all the time. I eventually wrote a very small lib for my websites that will alert that 1) the server gave an invalid response (basically, it isnt json that is returned or is missing a required field), if the op was succesfull, an error (such as user is not logged in) and misc things like redirect on success.

Is there a standard library i can use for this? right now my syntax is something like the below. Is there anything out there like this (or is pretty standard to use while deal开发者_运维问答ing with ajax/json?)

I also have a tiny (like 10line) implementation to talk to it on server side (.NET)

$.ajax({...
    success: function (data) {
            if (handleResponse(data)) {
                //success code. Most of the time empty bc it will redirect or refresh the page
            }
            else {
                //error code. remove readonly from textboxes and disables on buttons.
            }


This might help you: JSend

It's standard way of formatting your JSON response for representing different server statuses and error messages, data, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜