Skip to content

Tag: javascript

Download file with ajax and php – readfile not working

I want to save a value to a txt-file and download it to the user. Right now, the value is being printed into the txt-file correctly, but the readfile function is not triggered, thus no downloading begins. The php, this code is located on the same page as the ajax call. The javascript, there is no url because …

Password in confirm box Javascript

I have a Delete button in my PHP page which deletes a record. But when I delete that button I do a confirm box with: Can I make it so when they confirm they have to fill in a password? So what I mean is something like this And then they have to fill in a password Thanks in advance.

How can I set session variable with JavaScript

By using below code on button click I get the href attribute value, until this everything is fine but when I got my href link on button click we want to store it in the session variable (i.e. var href) because we also use this variable elsewhere. Please suggest me how to store JavaScript variable in session.?…

How to escape Twig like variables on JS

I need to escape some JS twig-like variables in a twig template, but I couldn’t find anything about how to do that. This variables are used in a js templating plugin that uses the same pattern as twig for variables which is causing the twig rendering to fail Unexpected token “punctuation” of…

Setting Cookie on click

I’m having an issue creating / setting a cookie on the click of a link, is there a proper way to do this? Either PHP or Javascript is fine. Obviously both JS and PHP wouldn’t exist in the same instance it was just to show what I have. Answer You can’t mix JavaScript and PHP. By the time your…