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 8460805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:42:31+00:00 2026-06-10T13:42:31+00:00

I have no problem creating an AJAX call, but each url must at the

  • 0

I have no problem creating an AJAX call, but each url must at the moment be unique. I wish to contain multiple PHP functions within the same file, and specifically access one of the PHP functions with a particular AJAX call.

Using jQuery, at the moment I am passing the .data parameter with an integer specification, then using the $_GET method in the PHP file and running the proper function specified by the integer.

How can I do this better? I want to call a specific function amongst many in a PHP file; I do not want to have individual files for each function

  • 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-10T13:42:32+00:00Added an answer on June 10, 2026 at 1:42 pm

    I could tell you to go with the quick and dirty solution, i.e. passing a function param in the call, then:

    switch($_GET['function'])
    {
    
    case 'show':    
        show();
        break;
    
    case 'delete':
        delete();
        break;
    
    case 'awesome':
    
        awesome();
        break;
    
    }
    

    But this is totally unmaintainable, because you will drown into a mess of includes, or even worse into a huge column of code you won’t be able to reuse anywhere.

    I advice you to get into routing, i.e. setting up a relationship between the URLs being pointed at, and functions being called, making use of parameters if needed [like in the second example below]:

    /users              --> printAllUsers
    /users/123          --> printUser($id)
    /products/beers     --> printProducts($category)
    /search             --> search()
    ...
    

    This way you are decoupling the routing itself from the response generation: you can find a better overall explanation here, then you can find a very good an thin library here you can use in your projects without relying on a whole framework.

    Ah, before getting in buzzword oceans with thing like OOP, MVC, RESTful service – which all deserve to be learned of course – stick with this first concept: it was the one I really missed when I began learning all this stuff, and it was the eureka for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an insert process in php but I have a problem in
An ajax call creating problem. It works fine in browser but through ajax it
I am creating a PHP site and have ran into the following problem, i
I have a problem in creating an AJAX-based form submission which if its response
Hello Guys! See I have been creating a code powered with ajax but it
I have a simple ajax call: $.ajax({url: my_url_here, dataType: 'text', success: function(data, textStatus) {
I must be missing something, silly, but here is the problem. I have a
I am creating an AJAX PHP upload script, but I am having troubles. After
I have a strange problem with native Ajax request invoking. I am creating the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

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.