JS problem

211 views
Skip to first unread message

sarjera...@flowian.com

unread,
Apr 15, 2015, 1:21:27 AM4/15/15
to suppor...@runmyprocess.com
Hello Team,

I have following JS script,
-------------------------------------------
function call1()
{
//statements;
}

function load_item_ko(result)
{
alert("ko "+JSON.stringify(result));
}

function load_item_ok(result)
{
alert("result ok "+JSON.stringify(result));
}

statement1;
test_collection.aggregateCallback(my_pipelines, {}, load_item_ok, load_item_ko);
call1();
statement3;

----------------------------------------------

Now the problem is, When I execute the script the flow of script execution is as below
statement1---> function call1()---> statement3-->load_item_ok/load_item_ko(depending on the result)

But what I expect is
statement1--->load_item_ok/load_item_ko(depending on the result)--> function call1()---> statement3

Please suggest the solution for the above problem.

Thank you.

Regards,
Sarjerao

Pankaj Kumar

unread,
Apr 15, 2015, 5:57:51 AM4/15/15
to suppor...@runmyprocess.com, sarjera...@flowian.com
Hi Sarjerao,

Call to fetching the data from the server is asynchronous, java script do not wait for the data to load to execute the next line of code as its uses the event for this.

   
You can modify the code as follows to ensure the order of execution of the code.

     function call1()
        {
        //statements;
        }

        function load_item_ko(result)
        {
                alert("ko "+JSON.stringify(result));
                     call1();
                     statement3;

        }

        function load_item_ok(result)
        {
                alert("result ok "+JSON.stringify(result));
                call1();
                statement3;

        }

        statement1;
        test_collection.aggregateCallback(my_pipelines, {}, load_item_ok, load_item_ko);
   

Thank you,
Pankaj Kumar
Fujitsu RunMyProcess Support


--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/d759f2f8-7d81-43dd-acb6-ff9fc3594d75%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.

sarjera...@flowian.com

unread,
Apr 16, 2015, 2:40:03 AM4/16/15
to suppor...@runmyprocess.com, sarjera...@flowian.com
Hi Pankaj,

Thank you so much for your support.

Regards,

Sarjerao
Reply all
Reply to author
Forward
0 new messages