Search code examples
phpjqueryajaximappartial-page-refresh

Refresh portion of website on hyperlink click


So, I have I'm making a PHP Mail website for myself, and I don't like how it refreshes every time I click a new mail/email/folder etc.

So, I was wondering if their is a way (I know their is, and with AJAX from what I've collected through Google), to have it log me in to a new mailbox, differing with the folder or with the actual email/host/ports/passwords.

Example:

If I click on an email in the list, it loads the "Message View" and refreshes ONLY that part of the webpage with the message. So it'd just be:

echo imap_fetchbody($mbox,$mID,1);

where $mbox is just the mailbox, and $mID is just the message number.

Further, and similarly, I would like it to do the same for the actual imap_open function, as to change the email/port/host on a click, but again, NOT refresh the page as a whole, but rather just the folders/message listing.

$mbox = imap_open ("{".$imaphost.":".$imapport."/imap/ssl}" . $folder , $email , $password); 

Where all the variables are what they say, but they can change on the hyperlink click of a list of my emails.

I hope I was thorough enough, and I really just need either a tutorial, or a clear explanation of how this works/how I can get it to work.

Thanks a lot and have a good evening!


Solution

  • This tutorial might get you started:

    http://www.jensbits.com/2009/10/04/jquery-ajax-and-jquery-post-form-submit-examples-with-php/

    The tutorial uses form variables so you may want to send your variables using the data parameter in the ajax or post function:

    data: ({id : this.getAttribute('id')}),