this.user Posted December 16, 2010 Share Posted December 16, 2010 I have three files: /index.php /include/index.php /include/ajax.php the /index.php page is the landing page, which includes the file /include/index.php once the page loads, I make ajax calls to /include/ajax.php here is what the files basically looks like: index.php <html><body><? include('include/index.php'); ?></body></html> include/index.php <? session_start() unset($_SESSION['team']); $_SESSION['team'] = '9'; include/ajax.php <? session_start() $_SESSION['team'] = $_SESSION['team'] . ',9'; Pretty simple right? However, here is what is happening, every time I make a call ajax call to /include/ajax.php, the code in /include/index.php also gets executed and team is reset to 9! I am using jquery to make the ajax call: $("input:radio").live('click', function() { $.ajax( { url:'include/ajax.php', success: function (data) { alert('done'); } }); }); and when I view the value after each ajax call, it is set to just 9. This is not any other issue, other than the code in include/index.php being executed each time the ajax function is called. Why in the world is the code in include/index.php being execute?! Under what circumstance would such a thing occur? Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/ Share on other sites More sharing options...
trq Posted December 16, 2010 Share Posted December 16, 2010 How exactly do you even know it is being executed? Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/#findComment-1147908 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 and what is the output? Is it showing: 9,9 Have you tried to change /include/index.php to something else like /include/main.php The index.php script is run upon request to that particular directory. Whether in your ajax call it is requesting that directory before or after (not just the ajax.php file) could lead to the problem. Try to change the index.php name so there is no index.php in your include folder (which you shouldn't need anyway - it isn't descriptive at all of what the script holds). Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/#findComment-1147912 Share on other sites More sharing options...
this.user Posted December 16, 2010 Author Share Posted December 16, 2010 How exactly do you even know it is being executed? The the ajax I posted is stripped down, I am returning a json value, in which I have dumped the session variable. and what is the output? Is it showing: 9,9 Have you tried to change /include/index.php to something else like /include/main.php The index.php script is run upon request to that particular directory. Whether in your ajax call it is requesting that directory before or after (not just the ajax.php file) could lead to the problem. Try to change the index.php name so there is no index.php in your include folder (which you shouldn't need anyway - it isn't descriptive at all of what the script holds). yes it is showing, '9,9' no matter how many times I call the ajax. Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/#findComment-1147918 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 Did you try my suggestion? Renaming the include/index.php? Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/#findComment-1147919 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 Sorry, if that doesn't work - what are you wanting the output to be? 9,9 and then another ,9 for each request? ,9,9,9,9,9 ? Are you setting any other values to this session variable? Quote Link to comment https://forums.phpfreaks.com/topic/221816-911-most-bizarre-issue-i-have-ever-encountered-with-php/#findComment-1147920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.