0

Possible Duplicate:
passing variables from php to javascript

I am using this awesome jQuery Stick Notification Plugin which creates notifications upon clicking various buttons. I used the following code to display the notification box...

$(".notify").click(function() {
     $.sticky('The page has loaded!');
});

Can i make it display some PHP variables in place of static text message?

Hope i've made it clear enough.

Community
  • 1
  • 1
Nasir Zia
  • 564
  • 1
  • 6
  • 20

2 Answers2

4

Without making asynchronous HTTP calls, you will have to insert the PHP variable at server-side:

$(".notify").click(function() {
    $.sticky('<?php echo htmlentities($message); ?>');
});

Wrap it with htmlentities() just in case $message contains some chars that make the JavaScript string invalid.

uzyn
  • 6,625
  • 5
  • 22
  • 41
1

yes you can like

$(".notify").click(function() {    
 $.sticky('<?php echo "The page has been loaded"; ?>');    
});
John x
  • 4,031
  • 8
  • 42
  • 67