This question has already been answered:

If I try to create a section object, the script in this section falls. Why?

for (var i = 0; i < hrefs.length; i++) { $.ajax({ url: "https://cors-anywhere.herokuapp.com/http://vm1.culture.ru/abramtsevo/catalog/" + hrefs[i], type: 'POST', async: false, success: function(painting) { var link = "http://vm1.culture.ru" + $(painting).find('.catalog-detail__image img').attr('src'); var filename = fileName(link); var name = $(painting).find('h1').text(); var [ , author] = name.split(': '); var values = []; $(painting).find('.catalog-detail__properties__row .catalog-detail__properties__row__right').each(function() { values.push($(this).text()); }) var material = values[2]; var scale = values[5]; var the_creation_of_information = $(painting).find('.catalog-detail__image-title').text(); var [date] = the_creation_of_information.split('., ');; var museum = values[0]; var city = values[4]; var notation = $(painting).find('.catalog-detail__annonce__text').text(); section: { link[i] = link; filename[i] = filename; name[i] = name; author[i] = author; material[i] = material; scale[i] = scale; date[i] = date; museum[i] = museum; city[i] = city; notation[i] = notation; }; } });; } 

I want to create it, and then immediately send to the server as JSON.

Reported as a duplicate by Grundy members, Community Spirit Oct 5 '16 at 14:43 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • But its just to remove the filling of the section object, then everything works fine. - Timur Musharapov
  • But its just to remove the filling - did not understand what you say - Grundy
  • in this case, you don’t have a session object, and it’s not clear what you want to do, or send another request, or remove a variable from the current request - Grundy
  • If we remove "section: {variables};" from the code above, then everything works. And so, even console.log does not display anything after this site. - Timur Musharapov
  • I wanted to fill it, and then send it to the server. - Timur Musharapov

1 answer 1

 var section = { link: [], filename: [], ................ notation: [] }; for (var i = 0; i < hrefs.length; i++) { .......... section.link.push(link); section.filename.push(filename); .......... section.notation.push(notation); } 
  • What does this code do and how does it relate to the question? - Grundy
  • one
    This code initializes and fills the section object. As requested by the author - Anton Shchyrov
  • does not coincide with what is written by the author - Grundy
  • Maybe this is because the author's code is not compiled at all and he asks to indicate an error? - Anton Shchyrov
  • I meant filling logic - Grundy