cancel
Showing results for 
Search instead for 
Did you mean: 

jquery ajax on portal 7.4

Former Member
0 Kudos

Hi

We are moving on to Portal 7.4.

One of the features we have is consuming a web service.

Since I find it very complicated, I would like to know

if it is possible to use Jquery.ajax on portal?

Thank you

Rrgards

yuval

Accepted Solutions (0)

Answers (2)

Answers (2)

saar_dagan
Employee
Employee
0 Kudos

Hi Yuval,

Did yo manage to add jQuery?

BR,

Saar

rohit_singhal
Active Contributor
0 Kudos

Hi Yuval,

Yes, it is possible to use AJAX for Portal version 7.4.

I have used ajax calls successfully in my custom components for EP 7.4

Let me know in case you have any questions.

Best Regards,

Rohit

Former Member
0 Kudos

Hi

Is there a comprehensive tutorial on this?

How it it done?

Is jquery loaded dynamically?

Tks

Yuval

rohit_singhal
Active Contributor
0 Kudos

Hi Yuval,

I would suggest following the below approach:

1. Load the jquery version that you want to use in KM.

2. In your jsp load include the javascript file.

3. You should now be able to use jquery functions in your jsp.

Let me know in case you need any further details.

Best Regards,

Rohit

saar_dagan
Employee
Employee
0 Kudos

Hi Yuval,

Consuming jQuery is quite easy.

My suggestion is to create an iView that you place on your framework page to manage all of your third party scripts (or else you will have lots of applications for no reason).

Create a portal component and use the PRT's IResource to add scripts:


public class myScriptsComponent extends AbstractPortalComponent {

    public void doContent(

        IPortalComponentRequest request,

        IPortalComponentResponse response) {

  IResource jquery =

  request.getResource(IResource.SCRIPT, "scripts/jquery.min.js");

  response.include(request, jquery);

  }

}

That is all to it.

Summary:

1. create portal component with above code.

2. create a folder inside of your component calls scripts.

3. add file name jquery.min.js (or whatever name you want just make sure you refer to it).

4. build and deploy the component.

5. find the application in the portal applications tree.

6. right click copy, right click on a folder you want and select "paste as PCD Object" (this will create an iView from the application).

7. add the iView to your framework page (if AFP then in the hidden container).

8. make sure you unchecked / set to false the "show tray"  property on the iView.

9. save.

You should now have jQuery available.

BR,

Saar

former_member190996
Participant
0 Kudos

Hi Saar,

I know this is a bit old thread. But I'm trying to do the same, using the jQuery with portal applications. Can you please let me know what type of iview should we create? Also, are there any kinds of documents that I can refer to?

Regards,

Sai

saar_dagan
Employee
Employee
0 Kudos

Hi Sai,

You need to create your own portal component, once you create it you open the folder "portal applications" under content management find your app, right click on the portal application you created and choose "copy" go to a folder, right click and select "paste as PCD Object" this will create the iView for you with the application as it's source.

BR,

Saar

former_member190996
Participant
0 Kudos

Hi Saar,

Appreciate your quick response.

I have created JSPDynPage portal component with the jQuery library under the scripts folder as shown below:

and I have written a sample code in the jsp as below:


<script src="scripts/jquery-3.1.0.min.js"></script>

<script>

$(document).ready(function(){

    $("button").click(function(){

        $("p").hide();

    });

});

</script>

Then, when I preview the iview I get the below error messages:

  • "NetworkError: 500 Internal Server Error - http://<host>:<port>/irj/servlet/prt/portal/prtmode/refresh/prtroot/scripts/jquery-3.1.0.min.js"
  • ReferenceError: $ is not defined

It can't find the resource under the scripts folder. Can you please let me know what am I missing here?

Regards,

Sai

saar_dagan
Employee
Employee
0 Kudos

Hi Sai,

But I said to so something completely different.. please read what I wrote.

BR,

Saar