I'm trying to make a ajax button to run a link with php code. In the code below when I click the button it gives a refresh on the page and does not run the line:
$.ajax({url: 'http://192.168.0.106:8080/v1/devices/'<?php $deviceID; ?>'/led/?access_token='<?php $dispositivo ?>'?params=l1,HIGH', success: function(result){
I want it to only run the line, without refreshing the entire page, where is the problem?
<?
echo "<form method='post' action='test.php'>";
?>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({url: 'http://192.168.0.106:8080/v1/devices/'<?php $deviceID; ?>'/led/?access_token='<?php $dispositivo ?>'?params=l1,HIGH', success: function(result){
$("#div1").html(result);
}});
});
});
</script>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Liga</button>
<?
echo "</form>";//fim do formulário
?>