Radio button Ajax Call
by Taqi_Shah
HTML
<table>
<tbody>
<tr class="text">
<td colspan="4" valign="top" bgcolor="f2f2f2">
<input type="radio" name="module" value="1"/>Stationary
<input type="radio" name="module" value="2"/>Inventory
</td>
</tr>
</tbody>
</table>
<table>
<tr class="text">
<td colspan="6">
<div id="items_list"></div>
</td>
</tr>
</table>
JavaScript
$(function() {
$("input[name=module]:radio").change(function() {
var module_id = $(this);
var dataString = 'module_id='+ module_id.val();
alert(dataString);
$("#items_list").html("");
if(module_id.val()=='')
{
alert("select stock type");
}
else {
$.ajax({
type: "POST",
url: "ajax/request_fetch_items.php",
data: dataString,
cache: false,
success: function(){
$("#items_list").html( html );
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
}
return false;
});
});