0

I have several <select>'s on a page of which i'd like to populate using Ajax.

Problem Statement: Some ajaxcalls can take up to two minutes to execute. The result, causes the rest of the calls (which only take one second) to execute "after" the previous ajax calls.

enter image description here

On the network table, BSCS is fetched, then EPCOMON is fetched "after". Along down the line, each request is made only after the previous one has finished. I've done tests and validated that BSCS indeed does return around 2 minutes, and SAP, for example, returns in 1 second.

How can I get these requests to be made truly asynchronously?

I started out with a simple jQuery $.get call:

for select2 in $("select.select2-package[name^='component_bundle']")
  product = select2.getAttribute('data-product')
  $.get "/bundles/fetch_components.json?product=#{product}", (resp) ->
    $(product).val(resp)

And eventually moved on to see if i could force async (in case something was overriding the default jQuery async true value)

$.ajax
  url: "/bundles/fetch_components.json?product=#{product}"
  dataType: 'application/json'
  cache: true
  ifModified: false
  async: true
  success: (resp) ->
    console.log(resp.responseText)
    $("#component_bundle_#{product}").val(resp.responseText)
  error: (resp) ->
    console.log(resp)
    portal.showErrorDialog("ERROR", resp.responseText)

Both attempts yield the same result. each ajax call is executed one after the other. How can I make these requests work truly asynchronously?

ddavison
  • 28,221
  • 15
  • 85
  • 110
  • This may be restricted server-side. Some platforms queue up requests that are identified for the same session. With PHP, for example: [Two simultaneous AJAX requests won't run in parallel](https://stackoverflow.com/questions/15686572/two-simultaneous-ajax-requests-wont-run-in-parallel) – Jonathan Lonowski Oct 23 '17 at 19:07
  • this could be.. i'll delve into the configuration of my rails server to see if it's blocking – ddavison Oct 23 '17 at 19:15
  • just checked my rails config, switched to a thin server that allows concurrent requests: `config.allow_concurrency = true`. In my output, i still see requests coming up one at a time – ddavison Oct 23 '17 at 20:14
  • Can you show more loading waterfalls since all I see are 6 concurrent requests, and in chrome the concurrent connections per host limit is 6. In my mind all is as it should be. Maybe you can spread your load on more hosts and see if any change occurs. – Paun Narcis Iulian Oct 24 '17 at 12:35

0 Answers0