夏期劇場
夏期劇場

Reputation: 18325

Javascript to PHP rather then using Ajax?

I need to call a PHP Script and Run (a function) on the Server .. by calling from client side by using Javascript. I know only Ajax Call from Javascript.

Upvotes: 1

Views: 140

Answers (3)

geekman
geekman

Reputation: 2244

XMLHttpRequest is the best way, as far as I know, but there are other techniques too. There is the old school way some sites still use. Using hidden iframes and sending request through it.You create an iframe with javascript, append it with 0 width and height and the request the php file. The output must be script that somehow communicates with the parent window script.

Upvotes: 0

Asciiom
Asciiom

Reputation: 9975

No, you use a XmlHttpRequest (that is, I assume you don't want the user to experience any sort of page refresh).

To work cross browser easily I'd recommend using a library like jQuery which handles everything for you, everything is nicely encapsulated and abstracted so you don't need to worry about any of the details. That way calling your script becomes extremely easy.

Upvotes: 0

Quentin
Quentin

Reputation: 943142

Nothing that is well supported or practical.

Ajax is just shorthand for "Making an HTTP request from JavaScript without leaving the page".

PHP is heavily geared towards being a server side web language (so it is optimised for being accessed over HTTP). Browsers are focused on accessing content over HTTP.

Upvotes: 2

Related Questions