Send more than one JSON file in a single AJAX request

2

I am requesting two JSON files for the getJSON function from JQuery. I'm trying to send them via AJAX but I can not. I've done the following:

var data = '[{"agents": '+agents +', "projects":' + projects + ', "spaces": ' +spaces+', "events":' + events +'}]';
var data_json = JSON.parse(data);

Where agents, projects, spaces, and events were received through getJSON. The problem occurs in the call of the JSON.parse () function. How can I send all JSON variables in a single request?

    
asked by anonymous 19.12.2016 / 14:42

1 answer

1

If the data comes from getJson they are not strings;

var data = [{"agents":agents, "projects":projects, "spaces":spaces, "events": events}];

Leave it and send it normally by the ajax request.

    
19.12.2016 / 14:52