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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:11:45+00:00 2026-06-16T11:11:45+00:00

I know I can do this: //Jquery $.ajax({type: ‘POST’, data : {‘action’ : ‘foo’}});

  • 0

I know I can do this:

//Jquery
$.ajax({type: 'POST', data : {'action' : 'foo'}});

//PHP
if(isset($_POST['action']) && $_POST['action'] == 'foo')
{
    function foo()
    {
        //yeah
    }
}

But.. In a project I’m working on with a friend, he has set up the controllers to be able to have specific functions called using custom actions. For instance, say my view is using the controller of thing.php. From my Javascript I can just AJAX to a url like this:

'url' : 'thing'

So in this case, foo() would get called without a need for any ifs or switches (as far as I know)

To me, this is great and ideal but I’m not sure how it was set up. He isn’t around for the holidays to ask so I’m asking you guys.

Do you know how this is achieved? We are using a pretty typical MVC architecture. Sorry I am a PHP novice. Thanks!

  • 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-16T11:11:46+00:00Added an answer on June 16, 2026 at 11:11 am

    It looks like your friend is using .htaccess to rewrite URLS to add .php, perhaps with

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    

    Now if you call a URL like /thing it will actually call the file /thing.php on your server and execute it. Or in your case if your url is just thing without the starting / it will call the thing.php in the same folder your current page is in.

    Or perhaps he is rewriting everything to the controller and then adding the variable as command. Something like

    RewriteRule ^(.*)$ controller.php?action=$1
    

    Anyway, check your/his .htaccess file for clues

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

Sidebar

Related Questions

I am using jquery ajax option data like this $.ajax({ type: 'post', url: '/shop_pos/index.php?route=module/cart/callback',
I use jquery to post data to mysql. **In settings.php i have this short
Can someone let me know what is the difference between this and jQuery(this) ?
I'm using jQuery AJAX to grab some data from a PHP page and using
I have a function in jquery that looks like this. function interceptFilter(e){ $.ajax({ type:
I know this can seem a weird question but for me it would be
I know this can be done and i have seen it done using some
I know you can do this <%= Request.Form[0] %> But how do you do
I know you can do this to get vertical text in a tab header:
I know you can do this with virtual attributes, but what if the column

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.