Click here to Skip to main content
15,883,807 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
success: function(data){
  var res = JSON.parse(data);
                       
  var n='';
  $quantity=value(res.products_stock);
  for($i=1;$i<=$quantity;$i++){ 
  $.each(data{
    n += html(' '+$i+' ');  

  });
}

}


What I have tried:

The error appears only when the code inside the for loop that starts with------ $.each(data -----is given. Any helps are appreciated.
Posted
Updated 27-Apr-21 22:20pm
v3

1 solution

I'm not sure what your value() or html() functions are, but I'll assume they exist and they're valid. The problem lies at this part:
JavaScript
$.each(data{
  n += html(' '+$i+' ');

});

That's not a valid format for the .each function, it expects an iterable element as the first parameter, and then the element as the second:
JavaScript
$.each(data, function (e) {

Or use a lambda expression
JavaScript
$.each(data, e => {
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900