Using javascript in php file
ON profile. First I need to say that, you can post your data by ajax without page reloading or by direct post reload your page. As your question doesn't tag jquery, so i'm leaving ajax. Here is the example for post a form data, I mean reload the current page and post the form data in profile. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. In javascript how to send data to php file using post method Ask Question. Asked 4 years, 7 months ago. Active 9 months ago. Viewed 33k times. Email This BlogThis! Share to Twitter Share to Facebook. Newer Post Older Post Home. Mosconet 29 June at Webslesson 29 June at Webslesson 1 July at Unknown 29 June at Sandeep 29 June at Karachi 30 June at DJ unkown a. Webslesson 20 July at Then study the concept of server side languages and client side languages.
You can assign PHP value to javascript variable. There is a way to run php in client-side javascript not talking about server-side js here. Don't know if this is a very good idea, but you can.
As some people pointed out you have to keep in mind the php is evaluated on the server and then returned as static stuff to the browser who will then run the javascript with the added data from the server.
You have to tell the server to evaluate the js files as php files, if you are running an apache server you can do this with a htaccess-file like this:. Edit: On http page request this trick makes files with js extension be parsed by the php compiler. All php parts in the js file will get executed and the js file with added server data will be handed to the browser. However, the OP uses an html formated file probably with php extension , no js file, so in this specific case there's no need for my suggestion.
The suggested js solutions are the way to go. If the variable needs to get stored on the server, use ajax to send it there. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How can you use php in a javascript function [duplicate] Ask Question. Asked 10 years, 1 month ago. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.
0コメント