If you check it out I have a bit of a problem with the following, I have a form (webbooks.phtml) in which I use a jQuery function
http://pastebin.com/7Pbd43fC -webbooks.phtml ( is actually a menu and in fact a view where you type the product that you are searching for)
http://pastebin.com/q8RJWdb7 -webbookscontroller ( this is a controller, which uses an API to get the data out of an SQL data base based on the string/number...etc given by the webbooks.phtml)
http://pastebin.com/vuy9GUvP -index.phtml (this is the view space where the result should be viewed.)
This is the array that I get:
{"book_title":"Bioethics in the 21st Century",
"id":"1424",
"isbn":"978-953-307-270-8","
unix_name":"bioethics-in-the-21st-century",
"visible_online":"1"}
I can see this array when I
die((json_encode)$result);
and I want this array to get to my view (index.phtml)? I am new to PHP and I'm trying to do something that may be bad practice and may well be impossible. I'm basically just hacking something together to test my knowledge and see what PHP can do. Is this possible?
This is an example of basic usage of calling Zend Controller with ajax/json and get response to the same phtml, so you can use it in your code.
In .phtml file I have javascript which call (in IndexController) the action ajaxAction():
In IndexController the ajaxAction() should get request:
In any way I suggest to listen the @jakenoble and look at(learn) Context Switching in Zend.
If the result of your client-side call is just a redirect to another page, then why not do it all on a single controller/action/viewscript, as follows:
Even if you want to do it in two actions - one to show the form, another to display the results - I don't see what value you are getting from the AJAX call.
Am I missing some other requirement?
Doing it with the current structure, you'd have to save the results of the remote API call into the session and then retrieve it after the redirect. Do-able, but it strikes me as unnecessary if it can be done in a single action.