EasyUI Forum
July 07, 2024, 09:43:21 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 question  (Read 7984 times)
ClSoft
Jr. Member
**
Posts: 92


View Profile
« on: January 26, 2013, 03:45:03 PM »

Hi all
I'm working with combination of few programming languages and here is my problem:
I need to execute some code from JavaScript, fill some variable in other language (string) and when variable is filled, goes back to JavaScript and continue to execute JavaScript.
Now, it does not work on that way because JavaScript does not wait and check if variable is filled.
My JavaScript code is this:

Code:
function loadlocal()
{
  $.post("javascript_clicked",
  {
    clicked_name:"reload_test",   // when this executes, I'm going to fill my variable
    // I need here to wait until my string variable is filled and then continue ...
  });
  alert("filled?");
  // Now I see above alert before my variable is filled
}

Thanks
Logged
Ellipsis
Full Member
***
Posts: 113


View Profile WWW
« Reply #1 on: January 27, 2013, 12:20:22 AM »

Try the jquery done()

You use It to trigger an action when an Ajax call is finished.
Your submit should trigger a post action (var ajaxcall = jquery.ajax(.......)Wink

You can 'monitor' the ajaxcall with jquery.when(ajaxcall).done(function(){.....});

See the examples on the jquery website.
You can even push multiple ajaxcalls into an array And monitor the entire array.
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #2 on: January 27, 2013, 03:37:03 PM »

Hi
thanks, but I don't know how to implement it.
I saw jQuery examples but they work with JavaScript. I have some variable from external software (like VB).
I meant to go to other direction, like this:
when user click on button, JavaScript function is fired and it calls some hidden webpage (page2).
There my external application start to fill the variable (some big string).
Now I meant not to go back to JavaScript, but instead, I meant to run the code form page2 and that code should be executed on page1.
When my variable is filled, I need to run something like this (from page2):

Code:
  var rows = [];
  myFilledVariable;
  $('#tt').datagrid('loadData', rows);

and myFilledVariable contains something like this:

Code:
  rows.push({{id: 'aaa',value: 'val1'});
  rows.push({{id: 'bbb',value: 'val2'});
  rows.push({{id: 'ccc',value: 'val3'});

this code should be executed on page1 (#tt datagrid is located on page1).
on that way I must not wait on page1 until my variable is filled, instead I'm going to fill it and when it is finished, I display result on first page.
Is that possible, and if yes - how?
Thanks.

Update:
Is there any other way to call such code from page2 and which will load data on page1 (on #tt grid) :
  $('#tt').datagrid('loadData', rows);

Thanks!
« Last Edit: January 28, 2013, 05:05:41 AM by Clarion » 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!