So I have the following code :
function aFunction(obj, myData)
{
$.ajax({
type: "POST",
url: 'myUrl',
data: myData,
async: true,
dataType: 'json',
success: function(data)
{
// ???
}
});
}
The data
I receive (correctly) is an array of booleans. Now I need to show the jQuery objects according to each boolean : the number of jQuery objects and the size of the array is the same.
Now, the following works as my success callback :
success: function(data)
{
//obj.show();
var pcom_array = $.makeArray(obj);
for(var i = 0; i < data.length; i++)
{
console.log(pcom_array[i]);
if(data[i] === true)
{
pcom_array[i].style.display = '';
}
}
}
However, casting the jQuery object as an array and then iterating over the array doesn't feel very "jQuery-ish" to me. Is there a jQuery method or some other way that could smplify this?