skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    Welp, it was one of those "oh my god" type of issues. Thanks to those who posted here - you helped me get much further in my debugging than I did on my own.

    The issue is that my hosting platform needs a specifier for Python3. I received the following message back:

    The following python binaries are available:

    python3: Python 3.9.7 python3.8: Python 3.8.12 python3.9: Python 3.9.7

    Please use the binary for the version of Python you want.

    So, I changed my env from python to python3, and we're all set!


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search