Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello people.

I used ASP.NET AJAX to do something like this:

html button:
<button onclick="writeSomething();">

and then with JS
PageMethods.writeSomething(something);

and then on serverside:

C#
[WebMethod]
   public static void writeSomething(string something)


This is pretty usefull. I would like to know how could I to the same with PHP as server side language. I know PHP is a pure server side language, I've seen some solutions with jQuery and some frameworks, but I'm wondering if I can do that other way.

Thank you very much.
Posted
Updated 3-Mar-11 10:48am
v3

1 solution

PHP don't have similar methods. PHP webservices are like other languages use SOAP or XML-RPC protocols. Have a look at their manuals

http://php.net/manual/en/refs.webservice.php[^]

You may need to use the XmlHttp object to connect to the service using ajax. jQuery have inbuilt ajax function which under the hood use XmlHttp.
 
Share this answer
 
Comments
Maxdd 7 3-Mar-11 19:38pm    
Yes I'm using XMLHttpRequest for now.

Unfortunately not as agile as Page Methods, but it will have to do the trick for now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900