Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access a php script from javascript?

Status
Not open for further replies.

mondi

Programmer
Sep 10, 2003
169
0
0
AL
Hi to all!
I am completely new to javascript so sorry for my ignorance here.
My problem is like this: I have a php code which is supposed to connect to the database (Sql Server) which returns some values from database. I need to call this php code from javascript and also need to process the values that php code returns.

Hope I was undestandable in my terminology :)

Thanks in advance for any help

Country of eagles
 
Either that, or have the PHP run, and output the data into a json array, which your Js could then read and work off of.

Of course if you want it to be on the fly, Ajax is the way to go.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I am not sure if I can use Ajax, however I will have a look at it. Thanks

Country of eagles
 
If you can't use Ajax, then you can't call a PHP script from JS.

You can run the PHP script first and then have JS work off of the produced data, but not the other way around, simply because JS and PHP exist in different environments, and cannot directly interact.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi, haven't been at work these days. I tried to use jquery for this case and it seems like it is working, i.e. I am using $.ajax to call a php script.
But except this, I need to pass an array of values (which might be some ID-s) as parameter to the php script and then send back to the javascript (from the php script) another array (which are these ID-s, but filtered by a query in MS SQL).

Sorry if I am in the wrong forum and thanks a lot for any help, because I am completely new in php, javascript, ajax or jquery and I am really feeling lost here.

Thanks

Country of eagles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top