Hello i want to use Jquery ajax
echo "$(document).ready(function() {
$(\"#submit\").click(function(){
var n = $(\"#n\").val();
jQuery.ajax({
type: \"GET\",
url: \"function.php\",
data: \"n=\"+n,
success: function(results)
{
alert(n);
}
});
});
});";
but never it shows the alert(n);
Can you help me?
Edit: I try to do it with only js but dont work too.. here is it.
<script>
var n = $('#n').val();
$(document).ready(function() {
$('#submit').click(function(){
var n = $("#n").val();
$.ajax({
type: 'GET',
data: "n=" + n,
url: 'function.php',
success: function (results) {
alert(results);
alert("some");
}
});
});
});
</script>
<form action='' method='post'>
<select name='n' id='n'>
<option value='Lusiana'>Lusiana</option>
</select>
<input id='submit' name='submit' type='submit' value='Go'>
</form>
I'm using this code: https://github.com/papalevski/jQuerySlider/tree/master/jQuerySlider
the php is:
<?php
$n = ( isset($_GET['n']) ? $_GET['n'] : "");
echo $n;
?>