Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript function does not run when called from Flash
    primarykey
    data
    text
    <p>I have a .php page, which has a JavaScript function in it, and runs that function, if something is correct in MySQL database. I know the function works. </p> <p>So my php file looks like this:</p> <p><strong>thephp.php</strong>:</p> <pre><code>&lt;?php $should_i_run_the_function = checkDatabase(); if(!$should_i_run_the_function){die("you can't");} ?&gt; &lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" language="Javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; function myFunction() { /* works in browser */ make_an_AJAX_call_and_insert_something_to_database(); } &lt;?php if($should_i_run_the_function) { ?&gt; myFunction(); &lt;?php } ?&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This works as it should, when I open the page in browser.</p> <p>But when I call it from <strong>ActionScript 3</strong>, like this:</p> <pre><code>public function CallURL() { var request:URLRequest = new URLRequest('http://localhost/thephp.php'); var variables:URLLoader = new URLLoader(); variables.dataFormat = URLLoaderDataFormat.TEXT; variables.addEventListener(Event.COMPLETE, Ajax_completeHandler()); try { variables.load(request); } catch (error:Error) { trace("Unable to load URL: " + error); } } </code></pre> <p>the completeHandler function shows the content of thephp.php correctly, and it does not <code>die("you can't")</code> but it doesn't do the mysql insert in JavaScript.</p> <p>I tried to simplify the code as much as I can, so what could be the problem?</p> <p>Does JavaScript require the "client" to be a browser to run?</p> <p>I also tried <code>ExternalInterface</code> but it does not work for that function, and I would like to know if I can run the JS code by a <code>URLRequest</code>.</p> <p>Thanks !</p>
    singulars
    1. This table or related slice is empty.
    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. 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