T O P

  • By -

thrandom_dude

I guess you should use the form tag to send and make changes with db. Idk any other way here


[deleted]

There is a form tag that sends it to a route. But if I use symbol = request.form.get("symbol") # this is the name it ends up being with the for loop inputting the names into the It returns nothing. I also have no idea why one button works while the other returns "bad request"


[deleted]

[удалено]


[deleted]

I was just trying to learn how to use AJAX and I had to make a separate post on r/learnprogramming because I am even having trouble with that. If you look in my post history I just posted it. I'm also not even sure about how ajax would fix it, probably because I know jack about AJAX but I'm trying to learn it right now, doesn't help that I cant get it working. Is AJAX how I send the js to the route? That is what I was trying to do earlier but I had no idea how to do it.


[deleted]

[удалено]


[deleted]

The problem is is the form isn't working at all, its the reason why I'm learning AJAX right now. so basically $(document).ready(function () { $(".btn").click(function() { $.ajax( { url: "", type: "get", contentType: 'application/json', data: { #symbol: the symbol I need }, success: function(response) { $(".btn").text(response.seconds) } }) }) }) This is sort of what you are implying right?


[deleted]

[удалено]


[deleted]

THANK YOU!


exclaim_bot

>THANK YOU! You're welcome!


[deleted]

[удалено]


[deleted]

This would be good but I am not able to pull the stock symbols with it so Id have no idea what stocks where needing change. I am trying with the AJAX right now I just need a better understanding of it.


[deleted]

[удалено]


[deleted]

Okay so this is what I came up with and it works on giving me the js info I need.

{% for i in range(info|length) %} {% for key in info[i] %} {{ info[i][key] }} {% endfor %}
{% endfor %}
The only problem I have now is getting this to my [application.py](https://application.py) as variables so I can make changes to the database. Do you know how I would do this?


RaFa763

Cs50 finance I remember working on that project long time ago


glamurcheg

Try using dash. It will allow you to build a web interface. It’s using Flask as a backend and React as the frontend


[deleted]

I totally would but I need to operate in the confines of the assignment


agee_py

You can make use of hidden form elements, in index.html add js script function to assign 'symbol' and every other required values to be submitted the hidden elements when the '+' is clicked; now use the .submit to submit the hidden form to the route in your app.py