New Zenner
- Join Date:
- Oct 2009
- Posts:
- 93
- Plugin Contributions:
- 0
Can't include catalog functions in seperate PHP file.
So you mean I should change the folder location?
Views: 4,010
New Zenner
So you mean I should change the folder location?
Totally Zenned
Changing the folder location won't help as the only place from which your AJAX handler can invoke application_top will still be your admin's root folder.
New Zenner
I have resolved the issue by writing my own functions instead of using zen cart functions.
But here, i'm encountering a very serious problem with $_SESSION variables. In my root directory I set a session variable but when i try to access it on EZ pages i don't get that value rather I get 0.
How to resolve this issue?
Totally Zenned
Unless you're prepared to write your own version of Zen Cart's page and session initialisation routines, you resolve it by putting your ajax handler in the admin root folder and calling application_top to do the heavy lifting for you.
New Zenner
I don't understand what you mean by all this. Please explain in a different or easy way.
Sensei
Any script that you want to run from outside Zen Cart but access resources from within Zen Cart ... requires that you load application_top.
If you don't do that, then you need to re-invent all the core logic that Zen Cart runs on ... essentially recreating your own framework.
So ... if you want to access Zen Cart resources, use application_top.
New Zenner
Thanks for your suggestion, but i include application_top.php everything stops working in my application.
Totally Zenned
The two most likely reasons for this are:
fawad123:
Please explain in a different or easy way.Sadly, this simply isn't that easy. It can get very technical, especially when ajaxing into the admin, as you have to also allow for the session expiring on you. PM me an email address and I'll send you some working code to look at.
New Zenner
Your first point is correct. I'm loading application_top.php from different folder than admin but again the problem is if i copy that file to admin folder and include application_top.php and then give it AJAX call , it does not work. Otherwise it works fine.
Sensei
And, as I said before, using PHP error_reporting can help you see what PHP errors your scripts are encountering.
New Zenner
OK I will use this function to extract error details.
New Zenner
I have used the following line of code:
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);
in my root folder PHP file when this file is access from EZ pages using AJAX call I don't see any error but AJAX does not work.
The EZ Pages block all PHP errors.
What should I do now?
Totally Zenned
Where are you looking for the errors? How do you know that the AJAX hasn't worked? Which step in the AJAX process isn't working?
New Zenner
I'm using Jquery for AJAX call.
The Success function or any other function like Error or Complete does not execute once I send the AJAX Call.
I'm using json_encode to get everything back on EZ pages on Zen cart. After including Application_top.php file nothing comes back through JSON_ENCODE, rather i receive 0 bytes.
Totally Zenned
All you're telling us is that you're not getting a response after triggering an ajax message. But you telling us anything about what steps you've taken to work out whether it's a problem with sending your message, or with receiving it on the server, or with handling the message or with preparing the response or with sending the response.
You do suggest that you're using json_encode to send the response, but that's not what json_encode does. It's function is merely to take a value (usually an array for AJAX) in UTF-8 format and return a string in json format. It doesn't send it anywhere.
The situation you find yourself in is normal when developing ajax, since by definition, much of the processing is hidden away. I find the Firebug console feature invaluable for exposing the messages to and from the server.
Errors on the server can be seen in your site's or your apache log files, and if they're not reported there, insert some dumps of your own and write them to your own log files (or echo or var_dump trace information and pick it up in the ajax response shown in the Firebug console).
However, the only person who can do all this is you, as it requires access to your server, and possibly your admin (though your later posts suggest that you're doing something on your EZ-Pages rather than in your admin, so maybe not), and specific knowledge of the code you're writing.
New Zenner
Thank you so much for your detailed response. I will try to track the error and will inform you where the exact problem is.
Previously, I had enabled PHP reporting but no error was detected when AJAX stopped working after including application_top.php file.
I think Firebug is the right option at this time to track what the exact problem is?
I know you cant test what I'm trying to do but if you want I can paste the code here. Let me know if by pasting code here can give you better understanding of how I'm implementing AJAX. ?
New Zenner
Thank you so much for all your effort.
BUT I HAVE JUST GIVEN UP !
I have tried everything but i don't know why php file is not sending response back to JS file when I include application_top.php file.
New Zenner
I have given one more attempt to this issue. The following code is tested:
myphp.php file:
<?php echo 'Testing module'; require('../includes/application_top.php'); echo 'Code after Application_top.php'; ?>When I call this myphp.php file through AJAX I get only "Testing module" printed but no other message after application_top.php file is executed.
It shows that when require('../includes/application_top.php'); is executed it redirects somewhere else without giving any error therefore nothing after that line is executed. That is why I'm not getting any response from AJAX as soon as I include application_top.php file.
I hope now you can realize that there are some settings or some variables in application_top.phph which does not allow further execution of my php file.
Can you suggest any solution now?
New Zenner
this is late I'm sure but this was my solution. I needed to add the chdir. With out that no matter if I put the full path or not it would not work
chdir('../../');
require_once('includes/application_top.php');
Tell staff why this post should be reviewed.