简体   繁体   中英

show calendar events in div on same page

hello I'm new to the jquery I'm making events calendar I have done the calendar module. when I click on the date it goes to events.php page and show the events for the day. but I want to show events for the day in div tag same page call (index.php). when I click on the date link I'm passing query string to the events.php page and I get the events for the day so I need to pass query string to the events.php page and get events in the div tag withot going to the events.php page

this is my coding

<td bgcolor="green" style="color:#FFFFFF">
    <a href='events.php?id=<?php echo $actualDay;?>&year=<?php echo $cYear?>&month=<?php echo $cMonth?>'><?php echo($actualDay);?></a>
</td>

I want the link result to be displayed inside a div using jquery.

If i've understood the question correctly.. you want to call the events.php on the same page with no redircts? Check jQuery ajax

UPDATE

doesnt need to be a form.. can be loaded onReady or only href link. whatever you like

$(document).ready(function(){
//when you submit the form
$(".submitbutton").click(function() {  
var name = "bob";
  $.ajax({
    url:"events.php",
    type:"POST",
    data:"name="+name+"&email=<?php echo $email; ?>"....... ,
    success:function(response){
      //work with the response from echo in events.php
      alert(response);
    }
  });

});

}); //end of (ready)

EDIT

HTML

<a href="#" id="yourid" class="link">the link</a>

jQuery

//catches all clicks with class link
$(".link").click(function() { 
     //the ajax function

You have to perform an AJAX request to retrieve the data for a specific event and fill a hidden div with the data retrieved from the call .

In order to do the above, you have to create an empty , style it properly, and hide it. Then you need to create sort of a request handler page , which should contain the same logic as the events.php page but instead of displaying the details it will only return the data in either JSON or XML format . This returned data will be be parsed using javascript\\jquery on your calendar page and filled into your hidden div, which you will show when finish the procedure above.

You need to research the following and learn to use the following:

$.ajax()

This is also a complete example of the above:

Example

It might be appropriate to your case.

Note: You might also need this:

$.parseJSON()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM