I have two different buttons in my page. clicking on the first one must call a php file named derive_rules.php while cliking on the second one must call another file named derive_rules1.php using ajax. For same i tried following code. But it is not working,
<script>
$(document).ready(function() {
$(".deriver").click(function() {
var val = $("#keyword").val();
var agent = $(this).attr('rel');
if(val == '') {$("#keyword").focus(); return;}
else {
$.ajax ({
url: 'derive_rules.php',
data: 'kw='+val+'&agent='+agent,
type: 'GET',
dataType: 'json',
cache: 'false',
success: function(data) {
if(data.success == 'true') {
$("#results_holder").show();
$("#results").html(data.msg);
$("#keyword").val('');
}
else {
alert(data.msg);
}
}
});
}
});
});
</script>
and those are mu buttons
<td><b>+ New Rule</b></td>
<td><input type = "text" name = "Keyword" id = "keyword" style = "width:300px" placeholder = "Keyword or Phrase"/></td>
<td><input type = "button" value = "Verify" class = "Buttons deriver" rel = "<?php echo $_GET['id']; ?>"/></td>
<td><input type = "button" value = "Add" class = "Buttons deriver" rel = "<?php echo $_GET['id']; ?>"/></td>
</tr></table>
what changes should i apply on my code to make it work???? as i want