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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:31:12+00:00 2026-06-08T03:31:12+00:00

I have been researching and trying to learn the proper method to accomplish this.

  • 0

I have been researching and trying to learn the proper method to accomplish this. I have done the following but, I still have no change on my form. Is there anyway to see if the ajax call is even being made? Could anyone correct this code to figure out why I am not getting any change on the field in my form.

In my model I have the following function

     public function standardRate($country) 
    { 

    $country_std_rate = Yii::app()->db->createCommand()       
       ->select('AVG(rate_syr_mh)')       
       ->from('packaging_metrics')       
       ->where(array('like', 'country', '%'.$country.'%'))    
       ->queryRow();    

            echo CJSON::encode($country_std_rate);  

    }    

In my controller I have added this function as well as added ‘countryRate’ to my access control for all

public function countryRate() 
    { 
            $input_country = $_POST['country']; 

            $model = PackagingMetric::model()->standardRate($input_country); 
            echo CJSON::encode($model);  

            Yii::app()->end(); 

            $this->render('countryRate',array( 
                    'model'=>$model, 
            )); 

    }

This is my Jquery call in my form

  $('#PackagingMetric_std_rate').live('click',function() 
    {  

 var country =  $('#country').val();  

       $.ajax({  
               type: 'POST',  
               url: 'PackagingMetric/countryRate',  
               data: {country:country},  

                           success: function(data)  
                               {                                                      

                $('#PackagingMetric_std_rate').html(data); 

               } 

                               }); 

             });

However, nothing on my form changes with a value, I am using Yii-Debug-toolbar and not seeing any POST calls or any sql queries upon clicking the appropriate field on my form.

  • 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-08T03:31:14+00:00Added an answer on June 8, 2026 at 3:31 am

    Your url parameter for the $.ajax(); is wrong could be wrong.

    That is if you are not hiding the entry script (index.php), you will have to write:

    url: 'index.php/controllername/actionname'
    

    instead of:

    url: 'controllername/actionname'
    

    It would be better to use createUrl():

    url: '<?php echo $this->createUrl('PackagingMetric/countryRate'); ?>'
    

    (Ofcourse the echo above and how you include php code in js will depend on how you are including the js in the first place)

    And name your countryRate as actionCountryRate().

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

Sidebar

Related Questions

I have been researching this for a while but got no convinced answer. From
I have been researching all over the internet about this, and unfortunately cannot find
I have been researching this issue pretty extensively and cannot seem to find an
so I have been researching this all morning- and I'm pretty sure the code
I have been researching around trying to find the best way to begin developing
I have been researching this problem for a while now and I just can't
I've been researching this on Google and SO but I'm stuck, I think I'm
Before I get flamed with references to manuals, I have been researching this for
I've been researching this problem I have and I can't seem to understand it
I am a total JQuery newbie and I have been researching this for 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.