Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Store GetListItems in a global variable?

$
0
0

What is the most straightforward way to directly access or return the results of an array variable inside the .each(function) of a GetListItems completefunc without sending it to a CSS element in the document first?

The thought is to have only one SPServices call initially for a very short list which other client side code could loop through the array as needed.

Example (spservices 0.7.1a): 

var arr = [];
$().SPServices({
	operation: 'GetListItems',
	listName: 'VeryShortList',
	CAMLQuery: '',
	CAMLViewFields: '',
	CAMLRowLimit: 0,
	completefunc: function getXML(xData, Status) {
          	var k = 0;
		$(xData.responseXML).SPFilterNode('z:row').each(function() {
			var id	= $(this).attr('ows_ID'),
			title	= $(this).attr('ows_Title');
			
			arr[k] = {id:id, title:title};
			k = k + 1;
                        // push the array here ....?
		});
		// return resulting "arr" here ...?
	}
});

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>