By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,372 Members | 670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,372 IT Pros & Developers. It's quick & easy.

Can i call php file in Javascript file

P: 9
Can i call php file in Javascript file,?
how can call php functions in javascript file ?

Please help me out here

Feb 19 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 490
Hi, and first off can i say I like your name!!!! I mean mine being harsh aswel!!!

secondly back to business, how do you want to call the PHP, research a bit of ajax, you can submit a form to php using javascript, but it really depends on what you are trying to do
Feb 19 '08 #2

P: 9
I have pop up in php file. I have fade in - fade out functions in that PHP file aswell. Working fine.

But Now when i write this functions in .js file and call that file over in PHP file it still works fine.

Now the problem is::::: I want to call this .js file functions (for my pop up) to another function inside the .js file. But when i do that its not working.

I am using document.getElementById to get the pop up text from PHP file. I want to call this .js file functions (for my pop up) to another function inside the .js file. But when i do that its not working because when i use getElementByID .js file does not know where to find ID, which is in that PHP file. Remember i have already call the .js file in PHP file but it does not work.

So i thought the only way is to call PHP file in .js file

By the way my name is HARSH. In india it means JOY but Here in USA it means Cruel. But i am not cruel. My parents did not think that i will go to USA someday. Well i am not changing my name for this because i like it.

Thanks in advance...
Feb 19 '08 #3

Expert 100+
P: 490
Hi again Harsh,
You will need to post some code.

but heres some provisional information....

PHP files are held on the server, they respond to requests from browsers usually with html markup. Javascript is on the client machine and then cannot interact directly with PHP.
you CAN get variables to javascript which can be used later on, on the client machine, but not the other way (well at least not without posting). please be careful not to fall in the trap of thinking variables can be passed two ways between javascript and PHP.

I repeat my first statement again, please post as much code as you can so we can get a better idea of what you are trying to do.

Finally, my name is Harjit, and in school people shortened that to Harj, and the one of my friends with a speach impediment couldn't say the "J" sound, as used to call me harsh, and it stuck, and i used it as a tag name when i used to DJ.
Feb 20 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.