Search code examples
javascriptjqueryajaxajaxform

Outdated, broken AJAX request


Recently migrated files over, and updated ca.py to run in Python3 instead of Python2. I have this AJAX request and JavaScript alerts work right before it, but not after. There are no console or other errors, so I'm not sure what exactly is wrong. Code below:

alert(input);
      var request = $.ajax({
      url: "ca.py",
      type: "GET",
      data: {rule: ruleNumber, numSteps: numRows, inputVector: input},
      dataType: "html",
    });
    
    alert("request opened!");

The first alert of the input shows without issue. The second alert showing "request opened!" does not. Thanks in advance.


Solution

  • This snippet demonstrates that your code basically works - even if the given url does not return anything:

    // define some constants:
    const input=123,ruleNumber=7,numRows=5;
    
    alert(input);
      var request = $.ajax({
      url: "https://jsonplaceholder.typicode.com/users", // "ca.py",
      type: "GET",
      data: {id:7,rule: ruleNumber, numSteps: numRows, inputVector: input},
      dataType: "html"
    });
    alert("request opened!");
    // further down:
    request.done(function(dat){alert("received:\n"+dat)});
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    And in case the url actually returns something then the .done() will also fire.