How to send information back and forth from a javascript file to a python file [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
So I have an html file with javascript and a python file. In the javascript file, the user enters a string. In the python, I would like it to search it in an api, and then return the string to be displayed in the html file. How do I do this? I have looked up how to use AJAX and get/post methods, but nothing has worked so far. Also, I should mention I am using flask.

The basic mechanics of having an HTML page communicate directly with another program is web server programming. If you want the web server to execute python, then consider setting up a Django server. Learning how to set up a web server and getting the two programs to talk with each other may take a while if it is your first time.

Related

Reading a JSON file to edit [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was given a JSON file and told to read it to get a better understanding of how JavaScript programming works and edit this file to do what I need it to do. It's supposed to be a file to run some cleaning processes on client computers, so I just need to edit it so that they file will run all the processes I want it to run without having to send multiple commands to the computer through my RMM.
When I open the file however in Sublime Text 3 it looks like this. How do I get it to read as JavaScript programming language so I can edit it?
{"os":3,"procedure_type":1,"name":"Clear_PrinterSpool_DNSCache_EventLogs","description":"","version":"2.0","payload":"cX8e1mZa4ffL5OfFuWnR+cqMYnnhpC5Myt22X+nx5dMeS1BYFK5yLlxTPWDPMiw3c0XnZD7Y5zrPIRD9EIxuYLEAa3MYYHZVHhfIUb5MeDifqw3+FHhA/IjFcyL9eSzJ/Nmt2TLu5bPSTQkzqBT9GAdiL0YsDxqn8mpttL0mDCa0g5gJ0vfI41lynD0L8pma6dQ5b3+I+JhSq9irNcHMRrhUkL8dfRUrzIasT/s0q0Ksy0jVu/lcMH+ab0CFlxRMB3aP5dZkBkjTPa4n54pX8yOHejnTbi0qXxVJSBLmFeV4Usw8f/dzbzdR+NN/qSaLP2JU4GXdHjgAIwk0Xb09oFbOhJIu4r7rPku0zLcaq5YXufXXWgzHmBo0AFg1xkGztsfA639dlxZXECxVx4ykMJWnFGl4nowGqsflHSddA4/Q72Nr0ZUm0nM2VAyBhQe8HZ2Z1FwRdBzM8i/YsC6LTGXXjgnn0xin/W2+y+7P+t4n0UFFFAaRT68GuvA/IuwuRjNEIfwhRo5s+qf5D9N1Rbxb/+dvzVVIuwrUIa8HZFHLJM1m4NURNCOTI3aW2o+Qigeah2AOVK4i/mIo94GJ4cnm4odFlli70R8XuKVFzNuKAHfn/TvMorlTdeWaYlLGB67EMtVvGEgSDPCk0mSJkWMzzHm+bxZo+LIAAspBjZuivP68kSm+2FKpMWqlmlKvlx9M+oy+P0koePHx3Ndi4p+Lsm9/mgHyvp3ZdfgmPuMdzOvrMlcibzdAi6e+TohtcQIJpk/yk5OIHgTysbSahwACiwaSLwqLh4SfcQRmmBAn8GoIA+PyD4g3zyErJmaJo6HcpJUcH0g7ytV/rotVvpr+2zW49fPRnCcm8q5pt12qROby42bLUMp/rm03EM+MUKB6I+YzWHENm8tg/O7UDanCyz7DIBbDl4hob8KtL7PA0QDjd9KQ61l/Ld7fNQ9vjNDD+uVaGyDim1ANhwdPMX/nJmvKmVc37XOgEd0AsmicZ8W2FobZpM3yfAdxD3to52N9fwC7T9exYE50RG7+McS+mtd8BRicXe5QfSH5P12GDM9+LaaUVdKzm63FZzhyX/0xpGN97q1VNKPAa6CfO5D/LD21mCrrPeOCeYJ2lHtTo7cW2iu7AXx0WRusz9PX162D+eqeo/ZFmflQv4MpMxnc00pT+QRxX3YZhX/50YU=","payloadChecksum":"d80877609ce0b19f6dcbe3c35d57cd03"}
You can just create a backend call, the URL being pointed to the location of this JSON file.
In the result of that backend call, you will get the contents of the JSON file.

Does writing JavaScript in <script></script> tags inside a PHP file make it more secure? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Suppose I have an MVC structure. Does writing JavaScript in script tags inside a PHP view file make the code more secured?
Will it still be seen by the client in source code?
Will there be any issues because of this?
I have tried calling an Ajax in a PHP view, but my teacher told me not to do it. I thought the only reason why she told me not to do it was the code not to get too mixed up and unreadable. Please tell me about this topic.
Your php will generate page with your script tag and send it to browser - so it is not more secure. However if you move your JS code into separate file and link it in your page, the code will be more readable and easier to develop in future.
Code executed in the client (browser, frontend, whatever) will always be accesible thus not "hidden" nor "secure".
Code executed in the server (backend) may not be visible to the client (this depends on how you structure your code, how much secure it its, etc.).

The relationship between JAVA and html [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Is JAVA compatible with html and js? Can we work together other than jsp???
To link the WEKA function.We implemented the java code using jar, and we need the html and js links for visualization. Is there any other method of linkage besides jsp?
There are various ways of working with Web tech and Java. JSP is an old-school means of generating a Web page using Java code and supplying it to a browser. This requires an application server capable of handling HTTP and JSP. Another approach is to create an independent Web page and to communicate with a server that is running Java. The simplest approach is, again, to use an application server that supports HTTP.
Reading between the lines of your question, I think the various solutions will require more effort than you were hoping.

Should a markdown parser be client or server side [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm currently working on a PHP project, which should use markdown to display some text.
The question I ask myself now since there are markdown parsers for javascript and PHP is if I should parse the markdown Server or Client Side.
Pros Server-side:
Always the same, even on clients which have javascript disabled.
Pros Client-side:
More dynamic allows for Preview function.
Uses Clients-Resources instead of the Servers.
Did I miss anything?
What would you suggest?
Any help is appreciated!
Inspired by so-called Isomorphic Javascript or Universal Javascript, I suggest you to make the first rendering on server side; then when you update your page —using ajax— you make the rendering on client side. Doing so you would get the pros of both solutions:
a fast initial rendering of the page (no need to wait for the JS libraries to be loaded)
a reduced server load for following requests
an up-to-date user experience for edition

How to talk to a database from Javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want variables from my Javascript functions to be recorded in a database on my server and then posted back onto the html page. I know this may be easy with the POST and GET method, but I've been reading and I'm stumped. So if anyone could lead me to a sample that shows how to do this or show me here in an example of one that would help.
You need to use some form of server-side scripting language (such as PHP) to capture the data sent from JavaScript (presumably via means of AJAX's XMLHttpRequest object) and insert it in the database.
i.e.: There's no means of directly communicating with MySQL from JavaScript itself - you need to use a server-side scripting language to do this.
You might wanna read into Ajax which uses the XMLHttpRequest object to do exactly that.
Using this you can send data to and from a server side script. So that way you could "insert variables into database."

Categories

Resources