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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:17:57+00:00 2026-06-09T11:17:57+00:00

i am working on a voting section of my website built over Yii framework,i

  • 0

i am working on a voting section of my website built over Yii framework,i am using ajax to call a php script that should load an Answer model and increment the positive/negative vote,however this script cant access model Class of Answers,if i use require_once('Answer.php') it gives me ActiveRecord.php Class not found,..my script file is not a Class so i cant extend ActiveRecord Class ,i am wondering if there is a way i can load Answer model in my script without messing around with Yii code,i am a newbie on yii,Thanks
here is my js

function downVoteAnswer(id){
    var data= $.get("/codepacu/protected/models/votehandler.php",function(data){
    $('#ans-downvote-'+id).text(data);
    });

    }

Here is my php script file

require_once('Answer.php');
$model=Answer::loadModel(4);
$model->up_vote=$model->up_vote++;
$model->save();
echo $model->up_vote;
  • 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-09T11:17:58+00:00Added an answer on June 9, 2026 at 11:17 am

    This error is nothing specific to Yii, it is so with any PHP code:

    You can only use a class when it’s definition is available. In your case, the definition is only loaded partly. You already load the file Answer.php for the Answer model class, but that class is defined in more than one file.

    So this requires you more files to load. Identify all needed classes and require the related files.

    This can be a lot, so it is normally better to create some ajax controller endpoint within Yii itself.

    • Update content in AJAX with renderPartial (yiiframework wiki)
    • Simple Yii ajaxLink (by Bryan Marble; 12 May 2010)
    • Make ajax request in yii framework (by Handita Okviyanto; 2 Mar 2012)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a website that is bassed around voting for posts. the website
i have this jquery voting script, everything is working fine, it just that the
I am working on a comment voting system. I have a page profile_new.php?id=194 That
I am working on a PHP script that allows users to vote on certain
Are there any requirements gathering tools that have a voting system built in? Using
I'm working on a simple voting system, using php and sqlite. I prebuild a
I have a jquery/php voting system I'm working on. Once a user clicks a
Hai there. I'm working on a voting script. I'll just post a code first.
ajax code- ... xmlhttp.open(GET,voting.php?qid=+qid+, uid=+uid+, type=+type,true); ... is this the correct way to sent
I have this site I've been working on here: http://www.replyonline.co.uk/DirectionGroup/xmas/index.php When you hover over

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.