Note that there are some explanatory texts on larger screens.

plurals
  1. POReferenceError: ajaxfunction is not defined
    primarykey
    data
    text
    <p>I've been unable to get an ajax script to run for some time.</p> <p>Basically, I need the user to select an option from one drop down box, then, based on what's selected, the second drop down box with populate accordingly based on a MySQL query.</p> <p>My Script looks like</p> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ $('select [name="front-size"]').change(function() { $.ajax({ url: '../functions/process.php', type:'get', data:{'value' : $(this).val()}, dataType:"html", success: function(data) { $("#sub").html(data); } }); }); }); &lt;/script&gt; </code></pre> <p>My initial drop down box is populated by a MySQL query like so</p> <pre><code>&lt;select name="front-size" onchange="ajaxfunction(this.value)"&gt; &lt;?php $door_size = $db-&gt;prepare("SELECT DISTINCT door_size FROM doors WHERE door_model = '".$_SESSION['front_door']."'"); $door_size-&gt;execute(); while($row = $door_size-&gt;fetch(PDO::FETCH_ASSOC)) { $size = $row['door_size']; echo '&lt;option value="'.$size.'"&gt;'.$size.'&lt;/option&gt;'; } ?&gt; &lt;/select&gt; </code></pre> <p>The second drop down box is empty</p> <pre><code>&lt;select name="front-finish" id="sub" onchange="ajaxfunction(this.value)"&gt; &lt;/select&gt; </code></pre> <p>And process.php should do the next query based on what was previously selected (this works on its own)</p> <pre><code>&lt;?php session_start(); include ('config.php'); $parent = $_GET['parent']; $update_option = $db-&gt;prepare("SELECT door_finish FROM doors WHERE door_model = '".$_SESSION['front_door']."' AND door_size = '".$parent."'"); $update_option-&gt;execute(); while($row = $update_option-&gt;fetch(PDO::FETCH_ASSOC)) { $door_finishes = $row['door_finish']; echo '&lt;option value="'.$door_finishes.'"&gt;'.$door_finishes.'&lt;/option&gt;'; } ?&gt; </code></pre> <p>In Firebug, when I select my first drop down menu, this error is shown and I've been unable to solve it.</p> <pre><code>ReferenceError: ajaxfunction is not defined ajaxfunction(this.value) </code></pre> <p>How can I fix this?</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.
 

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