cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share

rutaveejshah
Champ in-the-making
Champ in-the-making
Hi

I am using alfresco community edition 4.0d.

Can i call a webscript from client side javascript?

If yes then please give some example on that.

Please reply as early as possible.

Thank you in advance.
3 REPLIES 3

rjohnson
Star Contributor
Star Contributor
Yes you can


       _callScript: function FGLocationContraventions__cllScript() {
            this.actionURL = YAHOO.lang.substitute(Alfresco.constants.PROXY_URI +
                        "/farthest-gate/fg-location-contraventions?noderef={noderef}",
                           {
                              noderef: this.selectedLocation.value
                           });
            Alfresco.util.Ajax.request(
                   {
                       url: this.actionURL,
                        method: Alfresco.util.Ajax.GET,
                       successCallback:
                       {
                          fn: this._loadOptions,
                           scope: this
                       },
                       failureCallback:
                       {
                           fn: this._getOptionsFail,
                           scope: this
                       },
                       scope: this,
                       noReloadOnAuthFailure: true
                    });  
      },

      _loadOptions: function FGLocationContraventions__loadOptions(p_response)
      {
             // Do your stuff here
      }



Enjoy

Bob Johnson

Hi Thanks for Reply.

Please tell me i write this Ajax call is it right or not.

this.actionURL = YAHOO.lang.substitute(Alfresco.constants.PROXY_URI +
                        "/components/form?itemkind={itemkind}&itemId={itemId}&destination={destination}&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton={showCancelButton}&htmlId={htmlId}",
                           {
                              itemKind: "node",
                           itemId: fileInfo.noderef,
                           destination:"destination",
                           mode: "edit",
                           submitType:"json",
                           formId:"doclib-simple-metadata",
                           showCancelButton:true,
                           htmlid: this.parentId,
                           });
       Alfresco.util.Ajax.request(
               {
                  url: this.actionURL,
                  method: Alfresco.util.Ajax.GET,
                  successCallback:
                  {
                     fn: fnFormLoaded,
                     obj: this,
                     scope: this
                  },
                  scope: this,
                  execScripts: true
               });

rjohnson
Star Contributor
Star Contributor
Whilst I haven't tested your code, so I can't promise it will work, it looks reasonable enough.

What you have posted will return you a form that you can display in a dialog or popup window. Your function fnFormLoaded will receive the content, then you need to do something with that to display it.

Bob Johnson