Note that there are some explanatory texts on larger screens.

plurals
  1. POStore jquery result into a array (or something like that) to be used by another javascript
    primarykey
    data
    text
    <p>Appreciate some insight given the following code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { var soapEnv = "&lt;soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'&gt; \ &lt;soapenv:Body&gt; \ &lt;GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'&gt; \ &lt;listName&gt;video_player&lt;/listName&gt; \ &lt;viewFields&gt; \ &lt;ViewFields&gt; \ &lt;FieldRef Name='Title' /&gt; \ &lt;/ViewFields&gt; \ &lt;/viewFields&gt; \ &lt;/GetListItems&gt; \ &lt;/soapenv:Body&gt; \ &lt;/soapenv:Envelope&gt;"; $.ajax({ url: "_vti_bin/lists.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" }); }); function processResult(xData, status) { $(xData.responseXML).find("z\\:row").each(function() { var liHtml = "&lt;a href='" + $(this).attr("ows_Title") + "'&gt;&lt;img src='" + $(this).attr("ows_snapshot_file_location") + "' width=120 height=90&gt;&lt;strong&gt;" + $(this).attr("ows_video_description") + "&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;" + $(this).attr("ows_video_description") + "&lt;em&gt;" + $(this).attr("ows_video_length") + "&lt;/em&gt;&lt;/a&gt;&lt;br /&gt;"; //{missing code}// }); } &lt;/script&gt; </code></pre> <p>What code should I enter inside the //{missing code}// such that I can store the variable 'lihtml' into a array that can be used in any javascript? (I wish to use document.write() to display the "lihtml" variable.</p> <p><strong>UPDATE 1:</strong> After taking minus4 consideration, the code is as follows:</p> <pre><code>&lt;script type="text/javascript"&gt; var glob; $(document).ready(function() { var soapEnv = "&lt;soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'&gt; \ &lt;soapenv:Body&gt; \ &lt;GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'&gt; \ &lt;listName&gt;video_player&lt;/listName&gt; \ &lt;viewFields&gt; \ &lt;ViewFields&gt; \ &lt;FieldRef Name='Title' /&gt; \ &lt;/ViewFields&gt; \ &lt;/viewFields&gt; \ &lt;/GetListItems&gt; \ &lt;/soapenv:Body&gt; \ &lt;/soapenv:Envelope&gt;"; $.ajax({ url: "_vti_bin/lists.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" }); }); function processResult(xData, status) { $(xData.responseXML).find("z\\:row").each(function() { var liHtml = "&lt;a href='" + $(this).attr("ows_Title") + "'&gt;&lt;img src='" + $(this).attr("ows_snapshot_file_location") + "' width=120 height=90&gt;&lt;strong&gt;" + $(this).attr("ows_video_description") + "&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;" + $(this).attr("ows_video_description") + "&lt;em&gt;" + $(this).attr("ows_video_length") + "&lt;/em&gt;&lt;/a&gt;&lt;br /&gt;"; glob.append(liHtml); }); } &lt;/script&gt; </code></pre> <p>and at the other part of the same document, I used </p> <pre><code>&lt;script type="text/javascript"&gt; document.write(glob); &lt;/script&gt; </code></pre> <p>and now, I receive the 'undefined' error. Any insight?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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