nerotic Posted July 4, 2010 Share Posted July 4, 2010 Here's my $_SESSION start: <?php session_start(); $section = $_SESSION["nav"]; ?> My js: <script language="JavaScript" type="text/javascript"> $(document).ready(function() { $("div.tabs").tabs(".images > div", { // enable "cross-fading" effect effect: 'fade', fadeInSpeed: 600, fadeOutSpeed: 1000, // start from the beginning after the last tab rotate: false // use the slideshow plugin. It accepts its own configuration }).slideshow({autoplay: false, interval:5000}); $("a.lnav").onclick(function() { // Get the ID of the link var src = $(this).attr("id"); alert(id); // Send Ajax request to backend.php, with src set as "id in the POST data $.post("/backend.php", {"id": src}); }); }); </script> Here's backend.php: <?php // do any authentication first, then add POST variable to session $_SESSION['nav'] = $_POST['id']; ?> Why can't I get the alert(src) to work? Link to comment https://forums.phpfreaks.com/topic/206720-why-isnt-this-alert-working/ Share on other sites More sharing options...
RichardRotterdam Posted July 5, 2010 Share Posted July 5, 2010 My quess is that your not using the jquery click event try to change the following : $("a.lnav").onclick(function() { into $("a.lnav").click(function() { Link to comment https://forums.phpfreaks.com/topic/206720-why-isnt-this-alert-working/#findComment-1081239 Share on other sites More sharing options...
trq Posted July 5, 2010 Share Posted July 5, 2010 Also.... Why can't I get the alert(src) to work? Because your code says: alert(id); Link to comment https://forums.phpfreaks.com/topic/206720-why-isnt-this-alert-working/#findComment-1081262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.