Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The response you receive is pure text, as defined by the handleAs parameter of the ajax call. If you want to query the markup contained in this response with dojo.byId, you need to convert it into parsed HTML, creating a DOM for it. To do this, you can create a temporary html element with the response; then you can extract the part you need using dojo.byId. </p> <pre><code>load: function(response){ var tempDiv = dojo.create('div', {innerHTML: response}); updateDiv.innerHTML = dojo.byId('elemToExtract', tempDiv); wireEvents(); return response; }, </code></pre> <p><strong>EDIT:</strong></p> <p>The above contains errors, as dojo.byId requires a Document as second argument, and it does not accept a Node (see also <a href="https://stackoverflow.com/questions/1393546/dojo-dojo-byid-over-an-ajax-response/1395230#1395230">Seth's answer</a>); moreover, it returns a Node instance which cannot be assigned to innerHTML. Ina working solution, when you have the temporary element you need to extract the part you need using dojo.query. Then you can paste it inside the DOM of the real page using dojo.place. Notice that if you want to replace the previous content, you need to delete all the children of the target node with dojo.empty before using dojo.place.</p> <pre><code>load: function(response){ var tempDiv = dojo.create('div', {innerHTML: response}); var results = dojo.query('[id=elemToExtract]', tempDiv); if (results.length) { dojo.empty(updateDiv); dojo.place(results[0], updateDiv); wireEvents(); } return response; }, </code></pre> <p>Notice that the dojo.place and dojo.create functions was added in versions 1.2 and 1.3 respectively; if you have a previous version, it can be replaced using the DOM api:</p> <pre><code>load: function(response){ var tempDiv = document.createElement('div'); tempDiv.innerHTML = response; var results = dojo.query('[id=elemToExtract]', tempDiv); if (results.length) { dojo.empty(updateDiv); updateDiv.appendChild(result[0]); wireEvents(); } return response; }, </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload