Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this ajax request failing?
    text
    copied!<p>This is probably a simple problem but I don't understand why this is happening. Here is the reduced code:</p> <p>Ajax call :</p> <pre><code>mydata = {'action':'update','options':options}; console.log(mydata); $.ajax({ url: 'dt/scripts/stoplight.php', data: mydata }).success(function(data){ if (data == 1) { alert("Options Updated"); }else{ alert(data); } }) </code></pre> <p>My data looks like this:</p> <pre><code>action "update" options Object { OMS-S="0", OMS-N="0", OHS="0"} </code></pre> <p>To clarify, this is a copy and paste from the browser console. The object is a valid object and is being passed via get like so:</p> <pre><code>https://*pathtomysite*/dt/scripts/stoplight.php?action=update&amp;options%5BOMS-S%5D=0&amp;options%5BOMS-N%5D=0&amp;options%5BOHS%5D=0 </code></pre> <p>This request hangs indefinately.</p> <pre><code>https://*pathtomysite*/dt/scripts/stoplight.php?action=update&amp;options%5BOMS-S%5D=0&amp;options%5BOMS-N%5D=0&amp;options%5BOHS%5D=1 </code></pre> <p>To further clarify. Options is being generated like this:</p> <pre><code>$("#stoplight_apply").click(function(){ var radios = $("#stoplight_options").find("input:radio:checked"); options = {}; $.each(radios, function( key, value) { options[value.name] = value.value; }); set_stoplight_options(options); }) </code></pre> <p>This one works fine.</p> <p>If any of these options are set to anything other than 0 then the php script it is going to works great! If all of them are 0 then it hangs and loads indefinitely.</p> <p>I commented out all the PHP that could be causing problems so currently the script does this:</p> <pre><code>$action = $_GET['action']; //Get or update print_r($_GET['action']); print_r($_GET['options']); </code></pre> <p>Why is this happening?</p> <h2>UPDATE:</h2> <p>I think I found the problem. All I did was change the word 'options' to 'test' and the php to print_r($_GET['test']) and it works fine. WTH?</p>
 

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