var f2hGetListInJson = function (listName, siteName, fields, callback, query) { var $ = jQuery; if (fields == undefined) fields = ['Title']; if (query == undefined) query = ""; var viewFields = ""; $.each(fields, function (k, v) { viewFields += "" }); $().SPServices({ operation: "GetListItems", webURL: siteName, listName: listName, async: false, CAMLViewFields: "" + viewFields + "", CAMLQuery: query, CAMLRowLimit: 0, completefunc: function (data, status) { var error = $(data.responseXML).find('errorstring').text(); var error_code = $(data.responseXML).find('errorcode').text(); if (error_code == "0x82000006") { alert("UWAGA. Lista '" + listName + "' nie została znaleziona. Nie można kontynuować."); } else if (error_code) { alert("B£¥D: " + error_code + "\n" + error); return; } var result = []; //$($.browser.msie ? data.responseText : data.responseXML).find('row').each(function () { $(data.responseXML).find("z\\:row, row").each(function () { var item = {}; var row = $(this); $.each(fields, function (i, name) { item[name] = row.attr('ows_' + name); }); result.push(item); }); if (callback) callback(result, status); //console.log('result', result); } }); };