Click here to Skip to main content
14,660,942 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to call php function in javascript?
How to call php function in jquery?
Posted
Comments
Sergey Alexandrovich Kryukov 24-May-12 15:13pm
   
Perhaps by "call" you mean something unusual... :-)
--SA

Rate this:
Please Sign up or sign in to vote.

Solution 1

There is no such thing as "in jQuery", because jQuery is also JavaScript. From the JavaScript standpoint (I assume you use client-side JavaScript, server-side JavaScript is not used much), there is no such thing as "PHP", which works on the server side. JavaScript comes into play when a page generated by PHP is already sent to the client and loaded; the result of it is just HTML.

—SA
   
Comments
VJ Reddy 25-May-12 6:42am
   
Good answer 5!
Sergey Alexandrovich Kryukov 25-May-12 11:42am
   
Thank you, VJ.
--SA
ali sheibani 25-May-12 12:08pm
   
I have access to the bank without having to refresh the page with jquery
for rating a subject
Sergey Alexandrovich Kryukov 28-May-12 18:04pm
   
OK, so what?
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 2

call php function in javascript/jquery
You need to use AJAX. Use traditional XMLHttpRequest OR jQuery defined .ajax method for it.

http://api.jquery.com/jQuery.ajax/[^]
http://api.jquery.com/category/ajax/[^]
http://www.w3schools.com/jquery/jquery_ref_ajax.asp[^]
   
Comments
   
I would never call it a "call". This is not even the RPC unless you try hard to mimic it to some extent. You just send an HTTP request and get HTTP response. Calling it a "call" creates delusions which are hard to debunk.
--SA

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100