Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you found a way to do AJAX calls during the transaction? I haven't finished reading the whole spec, but so far it looks like once your <code>SQLTransactionCallback</code> or <code>SQLTransactionSyncCallback</code> returns, you can’t add any more stuff to the transaction — or can you? Maybe from the results callback?</p> <p>Edit: Now that I look again, the spec (which contains many fewer errors than the Apple document you linked to, but is not as easy to read) <a href="http://dev.w3.org/html5/webdatabase/#executing-sql-statements" rel="nofollow">says this</a>:</p> <blockquote> <ol> <li>If the method [<code>executeSql</code>] was not invoked during the execution of a <code>SQLTransactionCallback</code>, <code>SQLStatementCallback</code>, or <code>SQLStatementErrorCallback</code> then raise an <code>INVALID_STATE_ERR</code> exception.</li> </ol> </blockquote> <p>So I think that means there's no way to do it.</p> <p>Further edit: No, wait! As long as the <code>SQLStatementCallback</code> takes <em>some</em> time to get called, you could busy-wait doing <code>select 3 + 4</code> over and over again, each time from the statement callback of the previous <code>select 3 + 4</code>, until your AJAX call sets a flag somewhere that has the data you want. This is terrible programming (it'll eat lots of CPU for no good reason, might block lower-priority tasks like redisplaying the page) but I think it's probably the only way to keep a transaction open for an arbitrary period of time. Too bad you can't <code>select 3 + 4, sleep(1)</code> in SQLite.</p> <p>In general SQLite (the underlying storage engine here) rolls back uncompleted transactions. I haven’t yet tested the page-reload error case you're asking about. I would be very surprised if it was committed.</p> <p>By the way, thank you very much for posting this question. I had been trying to figure out how to get the transaction to rollback, even though <a href="http://dev.w3.org/html5/webdatabase/#processing-model" rel="nofollow">it is meticulously documented</a> in the original spec.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload