Jump to content

How do you call a php function from javascript.


bilis_money

Recommended Posts

let say i have a php function like this below;

function myfunc() {

etc...

}

 

now i have javascript below using onmouover();

<a href="" onmouseover="">

<img src="mypicture.jpg" width="" height="" border="2"/>

</a>

 

what is the proper way to insert php myfunc() inside javascript

onmouseover() function. So that i can call the php function.

 

is this correct below?

<a href="" onmouseover="<?php myfunc(); ?>">

 

they say it is not possible on javascript but it is possible on ajax.

actually i have to call a javascript function plus a php function

inside a onmouseover() how i would go about with this?

 

please take note i'm newbie on ajax.

 

Thanks in advance.

Link to comment
Share on other sites

You can't.  I don't know how many times this has to be repeated, but Javascript only occurs on the client and PHP only occurs on the server.

 

AJAX is merely a means of invoking a request on the server without refreshing or reloading the current page.  The request is made to the server, the server executes some PHP, the PHP spits out some plain text (as it always does), and then your Javascript interprets however you decide it does.

 

I won't explain the process in great detail, here are some pictures to help:

http://images.google.com/images?q=ajax+interaction+model&ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&sa=N&tab=wi

 

I suggest you step through a couple of AJAX tutorials before you ask further questions about the topic.  I would highly recommend researching the different Javascript event models as well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.