Hello,
I have recently ran into a issue with a component and the $AJAX_URL token.
Teamsite/Livesite 7.3.1
Windows
The goal is this.
My component has an external that runs a LSCS query based on a query parameter to the .page.
For example:
Going to "mine.page" my component runs a LSCS query that returns 1 doc.
Going to "mine.page?query=cat" my component returns 1+3 cat docs
Now my idea is to have a drop down with cat/dog/../../. When the drop down is selected a LSCS query is run and the correct docs are displayed. I would like to do this using AJAX without doing a page refresh and for that I have to use the $AJAX_URL token.
My approach:
On item change i run this call.
$.ajax({
url:'$AJAX_URL'.
data:query.
success:funtion(data){
alert(data);
}}}):This works, alerting the data shows the DOC that has the component <Data> with the correct number of Documents. Basicly this has the complete component.
Problem:
I was under the impression that running the $AJAX_URL would cause the component to render itself again with the new query paramter. This is not the case.
The problem is the Ajax return is the complete component xml and has not been parsed by the xslt or by the java engine. Idealy it would return the component output and I would just replace the content that would need to updated in the DOM.
From scouring these forms it seems that noone has a good grasp on how the $AJAX_URL token works, and the complete utter lack of documentation around it other then "look at the code" which is 6? years old and is not very straightoward. But I digress....
Possible Solutions:
1. Figure out how to call a .page file through $AJAX_URL (which documentaiton says has no paramters) that returns a .page file of XML-type that has my component on there. That would basicly make the ajax return a html snippet that i would subsutitute out.
2. Go the long route and change the Ajax return into json and spend about 50 hours converting it to proper html
and replacing the content. (basicly doing all the work of the xslt in javascript/json)
Im fairly sure what I have done should work.
$AJAX_URL Used by components to call into the external contained by that component and return a document. For examples of this token, refer to the AJAX based components. Replaces the URL with Ajax URL prefix (no parameter)
I have done this successfully when i had form submssions and iframes to do this but without a refresh to the component it just does not work.
Has anyone been successfuly in doing such an solution? Or any advice on how to resolve this issue?
It would be most helpful
Thanks
Bob