掲示板

Make ajax call inside javascript onclick method

thumbnail
10年前 に Muhammed Shafeek V によって更新されました。

Make ajax call inside javascript onclick method

Regular Member 投稿: 140 参加年月日: 13/07/22 最新の投稿
Hi ,
How to make an ajax call inside javascript onClick function?

<script type="text/javascript">
function helloTest(anchor,classPK) {
anchor.text = "unlike";
alert(classPK);


var subscriptionURL =
Liferay.PortletURL.createResourceURL();
alert("sub url");

}
</script>


That is my javascript code.

please help me
thumbnail
10年前 に Muhammed Shafeek V によって更新されました。

RE: Make ajax call inside javascript onclick method

Regular Member 投稿: 140 参加年月日: 13/07/22 最新の投稿
Now I can able to call ajax request.

<script
type="text/javascript">
function helloTest(anchor,classPK) {
anchor.text = "unlike";
alert(classPK);





jQuery.ajax({
type: "GET",
url: "<liferay-portlet:resourceURL></liferay-portlet:resourceURL>",
data : {
"HELLO" : "Like"

},
cache: false,
dataType: "html",
success: function(data)
{
alert("succc");
}
});



}
</script>


But I can't able to pass parameters ?
thumbnail
10年前 に Ritesh Gajera によって更新されました。

RE: Make ajax call inside javascript onclick method

Junior Member 投稿: 66 参加年月日: 12/02/21 最新の投稿
Hi ,

You can also get better solution from the below url:

Liferay Portlet+Ajax call inside Javascript

Regards,
Ritesh