Angular JS

Jquery Form Serialize()

봄산 2016. 11. 14. 21:32

html


<form name="ReadingInfoSelectForm" id="ReadingInfoSelectForm" action="" method="post">

<table>

<tr>

  <td>

사용자ID : <input type="text" size="50" name="UserID" value="hema30" /><br/>

도서ID : <input type="text" size="50" name="BookID" value="uuid:35aeb750-ee9f-4813-be49-c43a0df68475" /><br/>

  </td>

</tr>

<tr>

  <td align="right">

  <input type="button" id="ReadingInfoSelectBtn" name="ReadingInfoSelectBtn" value="전송"/>

  </td>

</tr>

</table>

</form>



JS



<script type="text/javascript">

$(document).ready(function() 

{

$("#ReadingInfoSelectBtn").click(function()

{

var formData = $("#ReadingInfoSelectForm").serialize();

 

$.ajax({

type : "POST",

url : "[요청URL]",

cache : false,

data : formData,

success : onSuccess,

error : onError

});

});

});

function onSuccess(json, status){alert($.trim(json));}

function onError(data, status){alert("error");}

</script>