Created
February 21, 2014 02:27
-
-
Save zhoumengkang/9127665 to your computer and use it in GitHub Desktop.
ThinkSNS的异步表单提交,把我自己封装的那个好像要高端很多,等会晚上回去好好研究下。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 异步提交表单 | |
* @param object form 表单DOM对象 | |
* @return void | |
*/ | |
var ajaxSubmit = function(form) { | |
var args = M.getModelArgs(form); | |
M.getJS(THEME_URL + '/js/jquery.form.js', function() { | |
var options = { | |
dataType: "json", | |
success: function(txt) { | |
if(1 == txt.status) { | |
if("function" === typeof form.callback) { | |
form.callback(txt); | |
} else { | |
if("string" == typeof(args.callback)) { | |
eval(args.callback+'()'); | |
} else { | |
ui.success(txt.info); | |
} | |
} | |
} else { | |
ui.error(txt.info); | |
} | |
} | |
}; | |
$(form).ajaxSubmit(options); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment