JavaScript Call A Function Directly - Separate Php File To Call The Function?

Dec 6, 2010

I am doing some basic Ajax stuff (not jquery.. just learning the basics), and I have a general structure set up where html calls a javascript function which sends data to and runs a specific php page.

But what if I just need to run a php function that's already defined in functions.php. Is that possible at all? I'm getting tired of making new php files for every task ;)

View 3 Replies


Call JavaScript Function Onclick Event Of Button When Function Define In Separate File

How do you call a JavaScript function from one PHP file that is defined in another PHP file?

View 3 Replies

Call Function That Is In A Different File From A Javascript Function To Retrieve Data From Database?

How do you call a PHP function that is in a different file from a JavaScript function?I have a JavaScript function that recieves a variable from an onClick function. The variable is an id that I will use to retrieve data from MySQL database. The variable is then passed on to a PHP function that will access the database to get the data and return back to my JS function for display, but it does not seem to be working. How can I get it to work? I am using CodeIgniter PHP.

Here is my code:

JavaScript in a different file called divUpdate.php

<script type="text/javascript"
<script type="text/javascript">[code]....

Then, in the controller home.php I have a function that the JavaScript uses to pass the id that will then be used by the model to retrieve the data from the database

function get_venue_description($venueID){
echo $this->venue_model->retrieveData($venueID);

For some reason the code in the JavaScript divUpdater.php doesn't work. It looks correct but doesn't work.

View 1 Replies

Auto Call Function For Every Other Function Call / Call Another Function Before Any Called Function Execution?

Class test{
function test1()
echo 'inside test1';
function test2()
echo 'test2';
function test3()
echo 'test3';
$obj = new test;
$obj->test2();//prints test2
$obj->test3();//prints test3

Now my question is,

How can i call another function before any called function execution? In above case, how can i auto call 'test1' function for every another function call, so that i can get the output as,


currently i am getting output as


I cannot call 'test1' function in every function definition as there may be many functions. I need a way to auto call a function before calling any function of a class.

View 6 Replies

Difference? Eval() Or Just Call The Function Directly?

I'm not php expert and I don't know what's the difference(1) between a and b.

a.)eval('return "'.base64_decode("encoded_text").'";')

-I THINK, a is php code and b is just string. And my other question is:What is the difference(2) between c and d?

c.)eval('return "'.base64_decode("encoded_text").'";')

View 3 Replies

Jquery - Call Class Function Directly Using Ajax?

Is it possible to call a php class function DIRECTLY using ajax? Something like below... except ajax.


I've been using the jquery library to work with AJAX.

$.get('control.php', {func: funcName, arg1: arg1});

The above is similar to what I'm trying to achieve MINUS the control.php; I'm not sure if this is even possible, but I just thought it would be nice to skip the landing page (control.php) that recieves the funcName. I have a bunch of conditional statements that sort out what class function to run based on the funcName recieved. It seems kind of silly to do this, to have a separate page just to handle function calls.

View 4 Replies

Syntax - Call Function From Parent Class Directly?

I have

class P {
function fun() {
echo "P";
class Ch {
function fun() {
echo "Ch";

How to call parent function fun from $x? Is it possible to do it directly or I have to write:


View 2 Replies

Call Both Function And Javascript Function For Click Of Single Button?

For the click of a button I have Validate the page through the Javascript and I have compare the data selected in the dropdown list with the database, that too before the page submit to the server. So I am planning to call two functions (Javascript and php function) for click of a single button. Is my approach (solution) is right or is there any other ways.

View 3 Replies

Make Automatic Javascript Function Call From Function?

I am trying to create an auto-refresh for a table using ajax/jquery, php/html, and Drupal 6. Code once the database insert has finished and was successful:

echo "<script type='text/javascript'>autoRefresh()</script>";

Code for the link that eventually calls the javascript code that actually performs the refresh of the table:

$block_content .= "<br><a id='refreshItemId' class='refreshItemLink' href='$host_url/refresh/projectitems/gid/$curr_gid/nid/$curr_nid'>Refresh List</a>";

Javascript code that is added to the page using PHP (I know it could be a javascript file and then include that, but that's for another day). This is the code I added to attempt to automatically make click() the link created above once a form is submitted and the item was successfully added to the database:


I thought this would have worked, but the autoRefresh() JS function never gets called.

View 4 Replies

Jquery - Call Javascript Function From Function?

What is equivalent of ScriptManager.RegisterStartUpScript() of Asp.Net in Php? I want to call some Javascript function from my php function i.e after some event is fired (may be adding record to database) i want to call javascript function. The event is fired using Ajax of JQuery.

View 3 Replies

Call Javascript Function

in this piece of code i would like to call a javascript function from php:

if (isset($_GET['ord']) && isset($_GET['type'])) {
//check if a reload of the select boxes is necessary
echo '<script language="javascript">orderReportsReload()</script>'

but the function doesn't get called....

View 1 Replies

Php To Call Javascript Function

Im not sure if this is considered a javascript or a php issue. I am trying to call a javascript function from php so that I can change a picture on the page without an event of any kind.

I have managed to call a javascript function from within php code which I have managed using the code below: Code:

View 5 Replies

Call A Function In JavaScript?

I have

<select id="year_list" name="year_list" onchange="check_year_event('year_list', 'event_list');" > . . . </select>
<select id="event_list" name="event_list" onchange="check_year_event('year_list', 'event_list');" > . . . </select>


how am I gonna call the PHP function evertime the user changes the value of any of the select element.

View 5 Replies

Call Function In Javascript ?

how to call php function in javascript ?

View 2 Replies

Call Function From Javascript?

ia m trying to call php function from javascript and return the alert box ... i was planning whenever i click the button of confirmation OK .. it will send out the email ... here is the code... i have trying so hard and cant run it .

<script type="text/javascript">
function confirm()


View 2 Replies

How To Call Javascript Function

i am trying to use gigya auth properties to login users on my website. They have a function that needs to be called after i authenticate the credentials as seen in this illustration. I have a form and when i submit the form i send it to login.php where i authenticate my users. My question is how do i call socialize.notifyLogin?. this is the javascript:


to be more clear i set the $talentnum; inside my login.php. so i have the form i send it ti the login.php and a redirect page. Where the call to socialize.notifyLogin will be?

View 2 Replies

Call To A Function(it Is In Javascript) ?

I'd like to ask how i can call a function which it is Javascript from php. Thanks



View 3 Replies

Call A Javascript Function?

I am trying to run a javascript function, RH_ShowHelp, that is stored in the file RoboHelp_CSH.js. The function itself should open a popup window containing our product's help system (written with Adobe RoboHelp) and the javascript file was supplied by Adobe as the standard call. I have managed to test the javascript in a straight HTML page which works, but I can't seem to be able to get this to work in PHP.

pURL )
$language = "javascript";

View 3 Replies

Call Javascript Function From Function

I want to call a javascript function from a php function like this:


but the function Buscar never show the alert but shows the $FechaMin.

View 3 Replies

Function Inside The Functions File Call Another Function ?

Can a function inside the functions.php file call another function from within functions.php? I'm guessing yes and which is why I wrote the code below, but it doesn't work for some reason. I tried calling pageBarColor() from register_sidebar()

if (function_exists('register_sidebar')) {

View 1 Replies

Javascript - Find Swfobject On Included Page And Call Javascript Function

I'm using the following script on my website to play an mp3 in flash. To instantiate the flash object I use the swfobject framework in a javascript function. When the function is called the player is created and added to the page. The rest of the website is in php and the page calling this script is being included with the php include function. All the other used scripts are in the php 'master'-page


I have a play-button with the id play1 and a stop-button with the id stop1 on my page. A div on the same page has the id status1 and a little image of a speaker is in the div. When you push the playbutton, the div with the speaker is fading in and when you push the stopbutton, the div with the speaker is fading out, very simple. And it works as I want it to do. But the problem is, when a song is finished, the speaker doesn't fade out. Is there a simple solution for this? I already tried using the swfobject framework to get the flash player from the page and call the IsPlaying on it, but I'm getting the error that wfobject can't be found. All I need is a little push in the right direction or an example showing me how I can correctly get the currently playing audio player (in flash), check if it's playing and if finished, call a javascript function to led the speaker-image fade-out again.

View 4 Replies

Call A Function From Javascript And Return The Results Back Into Javascript?

how I can get a web page to call a PHP function and have the results returned to the client for processing, for about two weeks. I hope I am in the right forum (ie. Javascript). I will also post in PHP and SOAP forums as well just to be sure. Here is the issue

PS: I don't have code to post because I really don't know how to implement this.

1. UserA loads a webpage from ServerA. In it it has a javascript function which "on web page loading" calls a remote function on another web server, ServerB. This remote function is written in PHP and accesses a MySQL database, the results of the DB query is an array.

2. This array gets returned by the remote server to the javascript function that made the initial call. The array then gets processed by the javascript function.

Now I know that Javascript is client side and PHP is server side. I also discovered that to make this happen I will need to use some sort of RPC functionality. Some sites/ideas that I have found on the net are............

1. XML-RPC [URL] using JSRS

2. and possibly SOAP.

I have spent the last few days trying to get ashleyIT's XML-RPC implementation to work but the documentation is scarce, the site and forum look like they aren't being used anymore, and I am starting to wonder if there is not a more popular/modern implementation that I should be considering.


So now the question. Does anyone know what implementation of RPC I could use? I am researching SOAP but so far I have not found a SOAP implementation using Javascript calling PHP functions. Is there anything else that I might be able to use other than XML-RPC and SOAP?

View 9 Replies

Call Javascript Function Using Code

How do i call a javascript function in an html checkbox onclick event???

echo '<TD><input name="checkbox" type="checkbox" value="'.$table['ID'].'" onclick="javascript:checkbox();">'

where my javascript function is below my <title>, was it correct that i put the function there?? If not how shall i place it??

View 3 Replies

Call Function With Param From JavaScript?

I'm trying to call a php function from javascript.

when I place a value in concatenation with a string does not work but if I put a fixed value without concatenate if I called the function correctly.

I leave the code I use. Function from my controller:

function size_make_dropdownlist($size_make_id)
$output = "<select id='size_make' name='size_make' style='width:100px;'>";
//$output .= $this->new_option('Seleccionar', '0', $size_make_id);
// $query = $this->car_model->get_car_makes();
$options = array('product_id' => id_clean($size_make_id));
$Q = $this->db->getwhere('omc_product_sizes',$options);
if ($Q->num_rows() > 0){
$query = $Q->row_array();
foreach ($query as $row)
$output .= "<option value=".$row['product_id'].">Talla ".$row['size']."</option>";
$output .= "</select'>";
return ($output);


function sizes(product){
var phpcodeis="<?php $size_make_dropdownlist=$this->MProducts->size_make_dropdownlist("+product+"); echo $size_make_dropdownlist; ?>";
//$size_make_dropdownlist=$this->MProducts->size_make_dropdownlist("+product+"); echo $size_make_dropdownlist; ?>"; //When use this line work perfectly but i need the another one


<a href="#"
style="display:block; color:#333; font-family:Tahoma; font-size:12px;"
onclick="sizes(1); return false;"> Sizes 1 </a>
<a href="#"
style="display:block; color:#333; font-family:Tahoma; font-size:12px;"
onclick="sizes(2); return false;"> Sizes 2 </a>
<span id="php_code_size"> </span>

or another way to do this?

View 2 Replies

Call A Function Every 3 Minutes Using Javascript?

I have a function that returns an integer (the current reputation score for a user on a community site). That number is often going up or down based on how their comments and submissions are voted on. I'd like to "poll" it every 30 seconds or so to see if it's changed, and if so, update the number that I'm displaying.

In another StackOverflow thread, I found this javscript snippet that looked useful:

function listen() {
$.get("/mylongrequestfile", {}, function(data) {
listen(); // then launch again

Do I just replace /mylongrequestfile with my function? I'm trying that but it's not working so well. How do I use this code, or some other snippet, to grab and display this value every 30 seconds?

View 3 Replies

Call Javascript Function With Code?

I am trying to call the Javascript function declared at the top in my php area. However its not working. Can anyone tell me the reason for it. Everything else is working except for this part.


View 4 Replies

Copyrights 2005-15, All rights reserved