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

  • Home
  • SEARCH
  • 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 6874669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:13:25+00:00 2026-05-27T04:13:25+00:00

Shortened Aim: To pass a variable via $.POST to a PHP file (get.php), and

  • 0

Shortened Aim: To pass a variable via $.POST to a PHP file (get.php), and for get.php to $.POST the variable again to db.php.

My Problem

I’m trying to follow the model-view-controller design pattern within my PHP code.

I’ll have three pages:

  1. index.php – The GUI (basically HTML and DIV tags)
  2. get.php – The hidden php which serves code via AJAX + POST to divs in index.php
  3. db.php – The database connection part

explanation image

Basically, I want to receive a response through two POST requests

So far I have index.php POSTING to get.php and requesting certain data, which is returned via and updated via AJAX and jQuery for animation.

Here’s a code snippet:

function get(div,id,opt_username) { 
$.post('get.php', { request: id },
function(response) {
    // In this order, first fadeout div
    $(div).fadeOut(600, function() {

        // If we pass a username as optional parameter...
        if (opt_username) { 
            //Prepend username onto response
            response = "     Welcome " + username + response;   
        }

        // Then get the response back HIDDEN
        $(div).html(response).hide(function() {
                // Once completed, parse with XFBML so everything renders
                FB.XFBML.parse(document.getElementById(div));
                // Only after everything's parsed do we fade back in
                $(div).fadeIn(1100, function() {}); 

        });
    });
});
};  

Now I can do POST requests to get.php, but if I try and do the same thing within get.php to post to db.php (to perform database operations) this just does not seem to work.

My Aim

index.php -> request data -> get.php -> request db connection -> db.php -> return data -> get.php -> return data -> index.php

This will allow me to switch the database layer out with another one. For example I’m currently using RDBMS but I would like to switch to XML / RDFXML in the future, meaning all I have to do is switch out the db.php for another one and everything will still work, keeping in-line with the MVC.

My Questions

  1. First and foremost, can I actually make a POST to a page to make another POST and if so, why am I getting the error below?
  2. Am I going about the Model View Controller approach the correct way

Further Explanation

Here is a code snippet in get.php (the second page) which throws an error:

$.post('db.php', { test: 2 },
    function(response) {} );

Error thrown:

Parse error: syntax error, unexpected '.', expecting T_VARIABLE or '$' 

Conclusion

I simply can’t get index.php to post to get.php, in turn posting to db.php.

  • 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-05-27T04:13:26+00:00Added an answer on May 27, 2026 at 4:13 am

    Implementing model-view-controller does not mean you have to create HTTP requests to communicate between these layers. Simply include the file using include or require. The seperation already exists by having different files.

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

Sidebar

Related Questions

I had a huge file for creating this GUI and I have shortened it
I shortened the code quite a bit, but hopefully someone will get the idea
In my Nant file I've got (paths shortened): <echo message=#### TARGET - compile ####/>
Here is my shortened code snippet: $(document).ready(function() { $.get(/Handlers/SearchData.ashx, function(data) { json = $.evalJSON(data);
I'm trying to store a shortened date (mm/dd/yyyy) into a DateTime object. The following
I have at least 4 tables in MySQL for my PHP application (shortened it
Is there a way to get the shortened t.co url from the API? I
I am trying to replace a URL with a shortened URL inside of a
I'm trying to convert the following (shortened for readability) to C# and running into
--Summary (shortened)-- I have a controller that loads a profile object from the corresponding

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.