Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:08:50+00:00 2026-06-01T02:08:50+00:00

I am calling a php function using ajax call but its not working. I

  • 0

I am calling a php function using ajax call but its not working. I have a table with some rows when I click on any column of a row it becomes editable with its value but when I edit the value and click on another column or enter the changed value is not displayed again. Actually I am doing an ajax call where I change the data of the column in my table but its not calling that php function.

My script is as follows

<script type="text/javascript" >
$(document).ready(function()
{
    $(".edit_tr").click(function()
    {
        var ID=$(this).attr('id');
        $("#span_"+ID).hide();
        $("#input_"+ID).show();
    }).change(function()
    {
        var ID=$(this).attr('id');
        var input=$("#input_"+ID).val();
        var dataString = 'id='+ ID +'&data='+input;
        $("#span_"+ID).html('<img src="load.gif" />'); // Loading image

        if(input.length>0)
        {

            $.ajax({
                type: "POST",
                url: "worker_app::edit_ajax()",
                data: dataString,
                cache: false,
                success: function(html)
                {
                    $("#span_"+ID).html(span);
                }
            });
        }
        else
        {
            alert('Enter something.');
        }

    });

    // Edit input box click action
    $(".editbox").mouseup(function()
    {
        return false
    });

    // Outside click action
    $(document).mouseup(function()
    {
        $(".editbox").hide();
        $(".text").show();
    });

});

The HTML table looks like this

<tbody>
  <tr id="{IDWORKERS}" class="edit_tr">
    <td class="edit_td">
      <span id="span_{IDWORKERS}" class="text">{FIRM}</span>
      <input type="text" value="{FIRM}" class="editbox" id="input_{IDWORKERS}" />
    </td> 
  </tr>
</tbody>

And the php function is inside apps folder in a file called wroker_app.php

public function edit_ajax(){
    ///echo "<pre>";
    ///print_r($_POST);
    //echo "</pre>";
   // sql to update the database goes here
    echo 'I am here';
}

Any ideas?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:08:51+00:00Added an answer on June 1, 2026 at 2:08 am

    You cant call a php function like this. You can only call a php file where you can decide which function should be executed.
    A simple example:

    $.ajax({
     type: "POST",
     url: "/apps/worker_app.php",
     data: dataString,
     cache: false,
     success: function(html) {
       $("#span_"+ID).html(span);
     }
    });
    

    And in your apps/worker_app.php:

    <?php 
    
    function edit_ajax(){
      echo 'I am here';
    }
    
    // You can put some logic before this line to decide which function to call based on the request
    edit_ajax();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: using jquery $.ajax to call a PHP function I need to call
I'm new to PHP and I'm confused seeing some examples calling a function with
I have two PHP scripts, both using the same session by calling session_name('MySessID') .
I'm using JQuery to call a PHP function that returns a JSON string upon
I have one php function on a seperate php file and I am calling
I want to select a particular Div after calling a php using $.ajax: my
I have a table where each row has a button that triggers AJAX call.
What are the 'costs' involved in calling an empty PHP function? The main purpose
When calling php via cli, the current directory is NOT changed to the one
Is there any way to include php file using require and calling a php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.