Issue in Passing Javascript variable to PHP file Through Ajax on Select -
i have jquery calender stores date onselect , want send selected date php file results database based on selected date.. code:-
enter code here<div id="calendar"></div>
date:
my scripr:-<script>
var x=''; $('#calendar').datepicker({
altfield: '#datepicker_send', inline: true, firstday: 1, showothermonths: true, altformat: "dd/mm/yy", dateformat: "dd/mm/yy", daynamesmin: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], onselect: function(datetext){ $('#event-date').text(datetext) x=datetext; // alert(x); $.ajax({ type: "get", url: 'check_events.php', data: { y : x}, //datatype: 'json', success: function(data) { alert(data); } /// tried value of date } ); } }); </script>
check_events.php:-
enter code here<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("users") or die(mysql_error()); if(isset($_request['y'])) { $y = date_format($_request['y'],'yyyy-mm-dd'); echo $y; exit; //trying print date //$uname = mysql_real_escape_string($x); $sql_check = mysql_query("select * events date='$x'"); while($res=mysql_fetch_assoc($sql_check)) { print_r($res); } } ?>
$.ajax({ type: "get", url: 'check_events.php', data: { y : x}, //datatype: 'json', success: function(data) { alert(data); //alert info on success not result. } });
javascript php jquery ajax
No comments:
Post a Comment