Ajax calling with manual passing the data
<form id='user_info'>
<input type='text' id='user_id' value='40'>
<input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>
<script type='text/javascript'>
function get_user_info(){
user_id = $('#user_id').val();
project_id = $('#project_id').val();
$.ajax({
url: '/create_user_information',
data: {user_id: user_id, project_id: project_id},
dataType: 'script',
type: 'POST',
success: function (data) {
}
});
}
</script>
Ajax calling with serialize method
<form id='user_info'>
<input type='text' id='user_id' value='40'>
<input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>
<script type='text/javascript'>
function get_user_info(){
user_id = $('#user_id').val();
project_id = $('#project_id').val();
$.ajax({
url: $('#user_info').attr('action'),
data: $('#user_info').serialize(),
dataType: 'script',
type: 'POST',
success: function (data) {
}
});
}
</script>
<form id='user_info'>
<input type='text' id='user_id' value='40'>
<input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>
<script type='text/javascript'>
function get_user_info(){
user_id = $('#user_id').val();
project_id = $('#project_id').val();
$.ajax({
url: '/create_user_information',
data: {user_id: user_id, project_id: project_id},
dataType: 'script',
type: 'POST',
success: function (data) {
}
});
}
</script>
Ajax calling with serialize method
<form id='user_info'>
<input type='text' id='user_id' value='40'>
<input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>
<script type='text/javascript'>
function get_user_info(){
user_id = $('#user_id').val();
project_id = $('#project_id').val();
$.ajax({
url: $('#user_info').attr('action'),
data: $('#user_info').serialize(),
dataType: 'script',
type: 'POST',
success: function (data) {
}
});
}
</script>
No comments:
Post a Comment