Click here to Skip to main content
16,016,527 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
$(document).ready(function(){
		 
		 function load_unseen_notification(view = '')
		  {
		    $.ajax({
		      url:"fetch.php",
		      method:"POST",
		      data:{view:view},
		      dataType:"json",
		      success:function(data)
		      {
		      $('#myDropdown').html(data.notification);
		      if(data.unseen_notification > 0)
		      {
		        $('.count').html(data.unseen_notification);
		      }
		     }
		    });
		  }


What I have tried:

i cant use session variables directly in fetch file so i feel i need to send session variables through ajax ...plz reply
Posted
Updated 7-Mar-18 2:18am

1 solution

First, you don't "SEND" session variable. If you have a session started then they exist for all pages in the session - so they aren't sent: you just use them.

For AJAX, you can send any values you wish when executing the XMLHttpRequest send() function. Since your using jQUery, you'll need to use their method.   I prefer straight javaScript.

How yous send values, which are essentially part of the URL, depends on how you invoke the send - they're retrieved on the other side in the $_GET or $_POST arrays, or $_REQUEST, which access both.

Here for "real" AJAX: AJAX Introduction[^]

You can find their jScript tutorial, as well, if you need it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900