Thanks Admin..Below instruction helps a lot.
But I am getting following error while calling http://localhost/cvv1/index.php?option=com_cvv&view=vvcitem&layout=ajax&render=subscribe
In the a case, all you need is to have models and controllers availables and working.
The controllers, receive the post of the ajax call (exactly the same)
The models, prepare and modify the datas (same as well)
All you need is to get the right SQL queries when you call objects, so if you didn't have created layouts for that, the predefined SQL queries will not be created.
So, to my opinion, the simpliest is to create all your fictive layouts, then delete them after download.
You must remove the template files (behind tmpl/ ), and the functions in the view.html.php refferring to that layouts.
IMPORTANT : As convention for the future of cook, when you deal with ajax, please set
in the GET or POST query.
So you will arrive in the
displayAjax() function of
view.html.php, and inside, you can switch the result, using the 'render' var :
layout=ajax&render=myExample
Of course, this
displayAjax() is automaticaly created for this view, when you decided to use Ajax for this context.
You can copy this function, but don't forget to add 'ajax' in the accepted layouts aliases in the display() function :
Ex :
if (!in_array($layout, array('default', 'ajax')))
return;
Then what to do ?
When layout=
ajax&render=
myExample :
displayAjax() :
in the switch, add a case : 'myExample', and write everything here (a. or b. cases)
Call a model and setup the context query (a context query has been already defined, or create a new one)
Note : Use the state vars to define the context :
$model->setState('default.myExample'); //HERE, myExample can be different than render
Populate
$myObject with this model (I don't explain in details what you already know)
in the b. case, you can use JDom to facilitate the rendering (see Ajax features, based on b. case)
and finish with :
in the a. case, finish with :
jexit(json_encode($myObject))
That's all for PHP.
JS in another post... to be continued