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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:59:19+00:00 2026-05-30T14:59:19+00:00

I’m a super beginner in php, and I’m using a MVC php framework called

  • 0

I’m a super beginner in php, and I’m using a MVC php framework called Yii. I can’t seem to find any articles that explain how to get values of html elements with PHP. Everywhere I look it’s all about how to get values from form fields after a POST in some other view. Is there anyway to get field values and send them to a controller in PHP and just come back to the original view.

In .Net MVC I just use jquery to get form fields and do an ajax call. It’s not sensitive data so I’m not worried about security. I like ajax because I don’t do any page post back, I just send my data over and remain on the same page I was on.

Is there any way to do MVC AJAX kind of thing with PHP? Read html element values and send them to a controller for data manipulation?

  • 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-30T14:59:21+00:00Added an answer on May 30, 2026 at 2:59 pm

    It works the same way. Yii comes bundled with jquery, so you

    just use jquery to get form fields and do an ajax call

    to some controller function, do whatever you want with it, and return a response, with php’s echo.

    If you already know some jquery, then the client-side shouldn’t be much different from .net mvc.

    Edit:
    To add a <script> to the generated html see registerScript.

    To create urls use the createUrl function.

    To add ajax options to html tags code looks similar to:

    echo CHtml::checkBox('mybox',false,
      array(// array for htmloptions, we also pass ajax options in here
        'class'=>'checkBoxes_class',
        'ajax'=>array(// this is ajax options for jquery's ajax
          'type'=>'POST',
          'url'=>Yii::app->createUrl('xyz',array('clickedboxid'=>'mybox')), // here you passed clickedboxid as a get variable
          'beforeSend'=>'function(){}',
          'success'=>'',
          // etc etc
        )
      )
    );
    

    Every html tag generator helper function takes htmlOptions array, where we can also pass ajax options.

    While reading these values in the controller:

    public function actionSomeAction($id){
       // $id is mybox
       echo "Hello"; // this is returned as response to the client
    }
    

    Hope this is enough for you to get started.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the 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.