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

HELP: returned php value as a javascript function parameter

P: 1
Hello Friends,

I'm working on a project which involves JavaScript and PHP and I'm really stuck.

I have a php file which returns a string (myPHPfile.php)

I would like to use this string as a parameter in one of my javascript function (myFunction(string)).

Expand|Select|Wrap|Line Numbers
  1. <body onload="load(); myFunction(myPHPfile.php);" >
But I don't know how to run myPHPfile within the code and recieve the value so that myFunction would run later.

Or perhaps I'm looking for a general answer of how to capture a value from PHP and use it in a JavaScript function as a parameter.

Thank you in advance.
Jan 7 '08 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Hello Friends,

I'm working on a project which involves JavaScript and PHP and I'm really stuck.

I have a php file which returns a string (myPHPfile.php)

I would like to use this string as a parameter in one of my javascript function (myFunction(string)).

Expand|Select|Wrap|Line Numbers
  1. <body onload="load(); myFunction(myPHPfile.php);" >
But I don't know how to run myPHPfile within the code and recieve the value so that myFunction would run later.

Or perhaps I'm looking for a general answer of how to capture a value from PHP and use it in a JavaScript function as a parameter.

Thank you in advance.
Javascript runs on the client side while PHP runs on the server. To get a PHP result to your Javascript function you can use AJAX.
Jan 7 '08 #2

Post your reply

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