EasyUI Forum
March 29, 2024, 05:45:15 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: javascript + ajax  (Read 3230 times)
rezzonico
Full Member
***
Posts: 182


View Profile
« on: April 10, 2018, 12:23:34 PM »

Hi all,

sorry if this is not a "jeasyui" question but it is part of my "jeasyui program".

I have the following two lines of code:

Code:
$('#id').append('text');
$.ajax({ async: false, ... });

I need to start the ajax function (the second line of the code) in "sync" mode.
The execution time of the ajax function is 10 seconds.

The problem is that the text (the first line of the code) is appended only at the end of the ajax function (after 10 seconds).
Is it possible to append the text immediately ?

Thanks.
Miche
« Last Edit: April 10, 2018, 12:27:23 PM by rezzonico » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 10, 2018, 04:54:32 PM »

Your second line will block the browser to refresh until it finished. The solution to solve this issue is to wait a little time to call your second line.
Code:
$('#id').append('text');
setTimeout(function(){
  $.ajax({ async: false, ... });
},400);
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #2 on: April 11, 2018, 01:35:30 AM »

Thanks !

Miche
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!