Order of commands

Can anybody tell me if there is an order to command strings.

Example:
I have a site with a server connect database query that auto loads with the page
I have a second server connect database action that inserts to the same table in that database.
Lets say I had a button not inside a form that executed the insert action, and then queried the table to show the result of the insert.
I would normally do an onclick that fires the insert, and a onsuccess of the insert to refresh the query action.
Could i rather do an onclick to fire the insert first and then in the same onclick tell it to execute the query, I tried it and it worked, well in about 20 of the 25 tests, so 4 out of 5 times it works, then i reverted to the normal way with a single onclick insert, and a single onsuccess query, and did another 25 tests, all 25 worked.

So my question is, why, does the onclick execute both commands at the same time, and sometimes the insert is still executing and the data has already finished the query?

Community Page
Last updated: