Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. jQuery.fn.serializeObject = function() {
  2. var obj = null;
  3. try {
  4. // this[0].tagName이 form tag일 경우
  5. if(this[0].tagName && this[0].tagName.toUpperCase() == "FORM" ) {
  6. var arr = this.serializeArray();
  7. if(arr){
  8. obj = {};
  9. jQuery.each(arr, function() {
  10. // obj의 key값은 arr의 name, obj의 value는 value값
  11. obj[this.name] = this.value;
  12. });
  13. }
  14. }
  15. }catch(e) {
  16. alert(e.message);
  17. }finally {}
  18. return obj;
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement