jquery - Javascript Ajax prototype in existing Framework -


i write quite bit of code in asp.net mvc , use jquery quite bit make ajax calls actions return json.

i've started evolve pattern make object below global object contains 'success' , 'fail' callback along 'go' method invokes core logic , takes arguments... follows:

var g1 = {}; // global object project...  g1.loadfilelist = {     success: function (data, status, request) {          // notify success - or nothing     },     fail: function (request, status, err) {          // notify #fail!     },      go : function (args) {         $.ajax({             url: '/home/somethinginterest',             type: 'post',              success: this.success,              error: this.fail         });     } }; $(document).ready(function() { g1.loadfilelist.go({ whatever = 'data' }); }); 

i keep thoughts organized , start working on different pattern start prototyping reuse of logging doing in error , success handlers, thought... in other js fx???

is it? thoughts on pre-existing frameworks similar things or thoughts on how prototype better welcome.

i'm going chalk to. pattern use sometime encapsulate async call success , fail response handlers.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -