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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:44:04+00:00 2026-06-05T22:44:04+00:00

I have jQuery load asset on my layout and I want to use CHtml::ajaxButton/ajaxSubmitButton

  • 0

I have jQuery load asset on my layout and I want to use CHtml::ajaxButton/ajaxSubmitButton.
But when I’m using it with another render on runtime it’s loading jQuery assets again and makes an error.
How to prevent the script from loading?

<?php echo CHtml::ajaxSubmitButton( 'Submit',
                                        CHtml::normalizeUrl(array('site/AjaxRequest/30')),
                                        array(
                                        'error'=>'js:function(){
                                            alert(\'error\');
                                        }',
                                        'beforeSend'=>'js:function(){
                                            alert(\'beforeSend\');
                                        }',
                                        'success'=>'js:function(data){
                                            alert(\'data from server: \'+data);
                                        }',
                                        'complete'=>'js:function(){
                                            alert(\'complete\');
                                        }',
                                        //'update'=>'#response',
                                        )
                                    );
    ?>
  • 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-05T22:44:04+00:00Added an answer on June 5, 2026 at 10:44 pm

    This is a pretty annoying issue IMO as well. The way I solved is to create a derived class of CClientScript and use that as the clientScript component (you can override the class type in your config file):

    'clientScript' => array
    (
        'class'                       => 'MyClientScript',
    ),
    

    My class overrides the “registerCoreScript” function, which is used for registering jQuery and other basic scripts that Yii includes.
    Pretty much what I do in there is add a check for ajax and not pass it on to the parent class if it is.
    It looks something like this:

    public function registerCoreScript($sName)
    {
       if (Yii::app()->request->isAjaxRequest)
          return $this;
    
       return parent::registerCoreScript($sName);
    }
    

    This prevents any core script being loaded (and adding assets again) during an ajax call.

    You can do the same for other functions in there too (eg registerScriptFile)

    Hope that helps.

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

Sidebar

Related Questions

I wish to use a jQuery .load(oracle apex url) query. I have a main
I have a script on jquery that load some site in iframe using: $(#demo_frame).attr('src',
Ok I have this problem I'm trying to use Jquery to load a partial
I have some problem to get the utf-8 string from PHP using jQuery $.load()
So I have a system using jQuery AJAX to load the content dynamically. I
I have a file input element which generate by ajax/jquery.load(). and when I want
I am using the jquery .load() method for a search. I have figured out
I have a problem using multiple (2) jQuery plugins. I've googled a little but
I want to have the jQuery AJAX load to insert before the navigation as-is
I'm using jQuery.load to load in some content but for SEO and for JavaScript-disabled

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.