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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:04:35+00:00 2026-06-07T17:04:35+00:00

Possible Duplicate: MVC ajax calls – where to handle them? I have a framework

  • 0

Possible Duplicate:
MVC ajax calls – where to handle them?

I have a framework which the overall view is as below:
enter image description here
This picture is from PHP 5 Social networking book, I don’t have the Page Object part. I dont have any problem with simple javascript/jQuery statements, but when it comes to JSON or Ajax where I need to fetch data then I’m confused! Beacause in JSON we need to put the url part. In an MVC there is no direct call. Everything will reach to Front Controller (index.php).
Now the question is how to handle JSON or Ajax requests in MVC? Should I create separate json php files in another directory to handle database connections,etc which is not Object Oriented?

  • 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-07T17:04:36+00:00Added an answer on June 7, 2026 at 5:04 pm

    I don’t know which framework you are using but, Zend Framework, for example has a mechanism that allows you to modify the format an action returns it’s data in. In Zend Framework this is called a context switch.

    You might want to check out how they implement that feature and see if you can either integrate it into your mvc or model it within your own mvc.

    http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch

    — Edit —

    It sounds like your framework does not delegate to controllers? If this is the case I would implement the solution you hinted at in your question and implement scripts that are consumed solely by your Ajax/REST calls.

    — Edit —

    Right so your front controller dispatches requests to controllers, that being the case I would recommend implementing context switching at the controller level, which will work using the same urls you would use in a standard request but would either read

    a) HTTP header info to see what response type you are asking for, which you would set in the AJAX request.

    b) send another parameter along in the url something like format=json that will switch the return type of your action.

    I would recommend reading the info at the link I posted as it might make things a little bit clearer.

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

Sidebar

Related Questions

Possible Duplicate: How to: Back button support “Ajax” I have a ASP.NET MVC implementation
Possible Duplicate: Schedule Controls for ASP.Net MVC I have MVC3 in which I want
Possible Duplicate: ASP.NET MVC: No parameterless constructor defined for this object I'm working on
Possible Duplicate: Client Id for Property (ASP.Net MVC) In my View I'm using jquery
Possible Duplicate: Caching in asp.net-mvc i have an asp.net-mvc site and i am running
Possible Duplicate: How to use multiple view engines in ASP.NET MVC application I am
Possible Duplicate: Alternatives to the MVC I have searched around for alternatives just to
Possible Duplicate: How can I get this ASP.NET MVC SelectList to work? What the
Possible Duplicate: ASP.NET MVC - Can i have multiple names for the same action?
Possible Duplicate: How can I properly handle 404 in ASP.NET MVC? I've made the

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.