0

Am using server-side JavaScript USE API to read the dialog properties like below

use(function () {
var myproperty = properties.get("renderpagetype");
return { callajaxvariable: myproperty,
};
});

How to pass/get this dialog property value and call an AJAX request in sightly.? (i.e. i need the dialog value which has been retrieved by JS USE API into a page level Java script usage).

krish
  • 469
  • 1
  • 15
  • 34
  • Please be more specific, what exactly is authored for the property "renderpagetype" and where are you sending an ajax request? – Ahmed Musallam Nov 27 '17 at 23:57
  • Its a string value and i need the string value from the dialog property to pass in a AJAX URI as a parameter for the REST call. – krish Nov 27 '17 at 23:58

1 Answers1

1

Here is a very simple example of what you are trying to achieve based on your question:

simple.js

use(function () {
  var myproperty = properties.get("renderpagetype");
  return {callajaxvariable: myproperty};
});

simple.html

// simple.html
<script data-sly-use.simple="simple.js">

  /* assuming you use jquery */
  $.ajax({
    method: "POST",
    url: "/path/to/backend/servlet",
    someParam: "${simple.callajaxvariable @ context='scriptString'}"
  })
</script>
Ahmed Musallam
  • 9,523
  • 4
  • 27
  • 47