I need some help with jQueury. I'm building a sidebar schedule which has a "Previous Day" and a "Next Day" button. What I want is if the user visits the website, it'll display the results for the current day (without clicking any buttons). But if the user clicks either "next" or "previous", it will show the results for the requested day.
The data is fetched from the /home/schedule/ url. For example, if the url is: /home/schedule/20130331, it'll fetch schedule signups for March 31st.
I have this code, however, it of course is not working. I'm not great with jQuery, so any help would be appreciated.
<div class="btn-group" style="padding-bottom:3px;">
<a href="#" id="prev" class="btn">Previous Day</a>
<a href="#" id="next" class="btn">Next Day</a>
</div>
<div id="displayResults" name="displayResults"></div>
<script type="text/javascript">
$("#next, #prev").click(function(e){
e.preventDefault();
$.ajax({
url: '{{ URL::base() }}/home/schedule/' + date,
data: date,
type: 'GET',
success: function (data) {
$('#displayResults').html(data);
}
});
});
</script>
datevariable?{{ URL::base }}? Are you using some templating system?