THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
require(["t5/core/ajax", "jquery"], function (ajax, $) { // Creating a callback to be invoked with <p id="result"> is clicked. $('#result').click(function() { ajax('answer', { element: $('#componentParagraph'), $('#result'), // This doesn't need to be the same element as the one two lines above // Callback called when the request is finished. // response.json is the object returned by the event handler method success: function(response) { $('#result').text(response.json.origin); } }); }); }); |
If you're trying to invoke a page class event handler, you can change line 5 above to element: null
. You do need to explicitly set the element
property, otherwise the ajax
function will treat the first parameter, url
, as an URL and not as an event name.