How to call function present in server Ajax processsor from client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 07:22 AM
Hi,
i need to call showCalender() function from client script.
How to call it?
i already know how to pass parameters from client:
schedulePage.addParam("myParam","myParamValue");
schedulePage.run();
but i don't know how return values from the server ajax.
that's why i need to know how functions can be called.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 11:01 AM
Hi there @mouli7
makee your Script Include is client-callable by extending AbstractAjaxProcessor.
Create the function showCalendar within the Script Include
var SchedulePage = Class.create();
SchedulePage.prototype = Object.extendsObject(AbstractAjaxProcessor, {
showCalendar: function() {
var result = {};
return JSON.stringify(result);
}
});
Use the GlideAjax class to call the server-side function from the client script.
function callShowCalendar() {
var ga = new GlideAjax('SchedulePage');
ga.addParam('sysparm_name', 'showCalendar');
ga.getXMLAnswer(handleResponse);
}
function handleResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var result = JSON.parse(answer);
console.log(result);
}
// Call the function
callShowCalendar();
If this helps upvote and kindly accept the response.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 08:49 PM
this solution you given is to crate a script include and making a call
but my question how to use the server ajax processor present in the screen shot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 11:36 AM
Hi @mouli7 ,
Please check below community links for same problem
Please mark my answer correct and helpful if this works for you
Thanks andRegards
Sarthak