cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute the web scrpt from HTML File

creddy2001
Champ in-the-making
Champ in-the-making
I created web script (JS, Description and Reponse template) in alfresco. If i specify the URL of the webscript in the browser (http://localhost:8080/alfresco/service/events/get), i am getting the proper response.

My question is how we can execute the web script from static html page and inject the response back in to the same static HTML (DOM) . Because my static html has different secitons. The response of the webscript is only a part of my HTML page.

Please help me out in resolving this issue. Its very urgent.

Thanks
Chandra
6 REPLIES 6

bramthielemans
Champ in-the-making
Champ in-the-making
Make an ajax request. Here's part of what you should do (using the YUI ajax library):

<script type="text/javascript">
   window.onload = function() {
      var url = 'http://localhost:8080/alfresco/service/events/get';
      YAHOO.util.Connect.asyncRequest('GET', url,{
         success: function(o) {      
            document.getElementById('eventlist').innerHTML=o.responseText;   
         }
      });
   }
</script>

creddy2001
Champ in-the-making
Champ in-the-making
Thanks a  lot. Its working fine.

creddy2001
Champ in-the-making
Champ in-the-making
I am facing new issue here. Every thing is working fine in my website. But from alfresco when i click on preview website, i am getting the permission denied script error. ( that is on making ajax request to execute webscript).

Please help me out in resolving this issue.


Thanks
Chandra

creddy2001
Champ in-the-making
Champ in-the-making
In this case i am getting the following script error.

Security Error: Content at http://admin.recoverywebsite.www--sandbox.127-0-0-1.ip.alfrescodemo.net:8180/ may not load data from http://localhost:8080/alfresco/service/events/get.


How to resolve this issue.


Thanks
Chandra

sethatrothbury
Champ in-the-making
Champ in-the-making
ajax can't make calls to a different domain. localhost != recoverywebsite 
You're going to have to change how your virt server is named.

lilyh
Champ in-the-making
Champ in-the-making
I have come across the same problem and have got around it using window.name transport.
Instead of using YUI I have used dojo to implement the execution of my web script.
Not sure if this is the best approach but it worked for me and I achieved results.
Below is the link to the tutorial I followed.

http://www.sitepen.com/blog/2008/07/22/windowname-transport/

and here's another one that may come in handy
http://www.sitepen.com/blog/2008/07/31/cross-site-xhr-plugin-registry/