Append a larger data to view after ajax post without freezing the browser.

How can I append a partial view after a ajax post? The partial view content size is 50-60 kb. So I,m using asynchronous ajax post and append that data. Now each content has only lesser than 10kb. But now I have append multiple data after every ajax success,
so browser has been hanged some interval of time(5-8 seconds) . How can I previent this?

Can any one one give suggestion this?

Hi LTAravindh,

please check that if you have set your ajax request  async as true. if it is set to false ,the browser will freeze until a response is received.

You can try the code below:

$.ajaxSetup({
    async: true
});

$.post(url,data,success,datatype);

Or you can try use $.ajax() equivalent:

$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType,
  async:true
});

Best Regards,

Kevin Shen.

That depends on the RAM size of the machine the website is being viewed on, since a lot of network requests hang the browser or the computer itself. You need to make sure, that you pass each of the data, one after the other. You can send the requests and
returns true if the previous data was recieved and processed. Once true, send the next amount of data. 

This error is a user related issue, and the machine related issue. You can minimize it, using lesser executions per seconds, if you’re uploading data, don’t download. If you’re going through algorithm, pause remaining threads. Using the Threadings of the
.NET Framework would be a great thing to work around with, but that is on the server side. 

Try using a time interval of the JS framework and send data after 1 second the ajax returns true. 

https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers.setInterval

LTAravindh

I,m using asynchronous ajax post and append that data.

What do you mean by "append that data"? Are you generating DOM elements (table rows or divs) dynamically from JSON or similar? You might find that returning an HTML snippet instead of data and using jQuery’s load method is more efficient.

Hi Kevin,

I tried as per your suggestion. At the time of ajax post browser has not been hang. Browser will be hang when I append DOM element.

Hi Mikesdotnetting,

In my question data represented as a DOM element.

Hi LTAravindh,

I am not quite sure how much data you append to your dom element.

If you did that ,the browser will hang .

I suggest that you can dynamically create the data /table in the server side, and append the  table into the page.

Best Regards,
Kevin Shen.

Leave a Reply