{"id":1,"date":"2020-12-26T23:12:49","date_gmt":"2020-12-26T23:12:49","guid":{"rendered":"https:\/\/xavierrecuenco.com\/?p=1"},"modified":"2021-12-27T09:28:09","modified_gmt":"2021-12-27T08:28:09","slug":"hola-mundo","status":"publish","type":"post","link":"https:\/\/xavierrecuenco.com\/index.php\/2020\/12\/26\/hola-mundo\/","title":{"rendered":"Call Ajax Script Include from Client Script"},"content":{"rendered":"\n<p>Previous actions: Create an Script Include and check .<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong> Script Include<\/strong> { \"Client Callable\"= true }\n<code>var scriptIncludeName = Class.create();\nscriptIncludeName.prototype=Object.extendsObject(AbstractAjaxProcessor, {\n\n    methodName: function() {\n     \/\/your code\n     \/\/how to Call another method in same class\n          this.methodName2();\n     \/\/how to Call method in differentClass(another script include)\n          var a = new differentClass();\n          a.otherMethodName();\n\t  return '';\n    },\n\n    methodName2: function () {\n\t\tvar obj = {};\t\t\n\t\tobj.username = gs.getUserName();\n\t\treturn JSON.stringify(obj);\n\t},\n\n    type: 'scriptIncludeName'\n});<\/code>\n<\/pre>\n\n\n\n<pre class=\"wp-block-verse has-text-align-left\"><strong> Client Script: <\/strong>\n<code>function onChange(control, oldValue, newValue, isLoading, isTemplate) {\n    if (isLoading || newValue === '') {\n        return;\n    }\n    if (newValue != undefined) {\n        var list = g_form.getValue(\"u_category\");\n        var ga = new GlideAjax('<code>scriptIncludeName <\/code>');\n        ga.addParam('sysparm_name', '<code>methodName<\/code>');\n        ga.addParam('sysparm_list', list);\n        ga.getXML(showITfieldsOnload);\n    } else {\n\t\/\/do something\n    }\n}\n<\/code>\n<code><strong>function showITfieldsOnload(response)<\/strong> {\nvar answer= response.responseXML.documentElement.getAttribute(\"answer\");\n    if (answer==true || answer.toString().toLowerCase()== 'true') {\n        \/\/do something id it's true\n    } else {\n        \/\/do something if it's false\n      }\n<strong>}<\/strong><\/code>\n<\/pre>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previous actions: Create an Script Include and check . Script Include { \u00abClient Callable\u00bb= true } var scriptIncludeName = Class.create(); scriptIncludeName.prototype=Object.extendsObject(AbstractAjaxProcessor, { methodName: function() { \/\/your code \/\/how to Call another method in same class this.methodName2(); \/\/how to Call method in differentClass(another script include) var a = new differentClass(); a.otherMethodName(); return \u00bb; }, methodName2: function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-service-now"],"_links":{"self":[{"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":5,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":19,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions\/19"}],"wp:attachment":[{"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xavierrecuenco.com\/index.php\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}