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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:50:29+00:00 2026-05-27T08:50:29+00:00

I put a Ajax link using the following code: echo chtml::ajaxLink(‘GO’, ‘http://localhost/index.php?r=user/delete’, array(‘method’=>’POST’)); But,

  • 0

I put a Ajax link using the following code:

echo chtml::ajaxLink('GO', 'http://localhost/index.php?r=user/delete', array('method'=>'POST'));

But, regardless of giving the second parameter as URL i,e ‘http://localhost/index.php?r=user/delete‘. It generates link with the current URL in the browser not the URL I just specified.
What is the issue? How could I create AJAX link? Google several hours but can’t solve the issue.
Any kind of help is highly appreciated.

  • 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-27T08:50:30+00:00Added an answer on May 27, 2026 at 8:50 am

    First of all, you should always try and create normalized urls.
    But i think your doubt lies in the # that is generated/appended. If you go and check the source of yii ajaxLink you’ll see this:

    public static function ajaxLink($text,$url,$ajaxOptions=array(),$htmlOptions=array())
    {
        if(!isset($htmlOptions['href']))
            $htmlOptions['href']='#';
        $ajaxOptions['url']=$url;
        $htmlOptions['ajax']=$ajaxOptions;
        self::clientChange('click',$htmlOptions);
        return self::tag('a',$htmlOptions,$text);
    }
    

    so if you don’t set the href property of the a tag in the htmloptions array, the # will be appended.

    You should also understand that yii uses jquery, so if you check out the source of the page, you’ll see at the bottom, how jquery is used to carry out an ajax request, your actual url that is called will also be seen in that script. So the third option/parameter in ajaxLink is for options for jquery’s ajax function. You can create better ajax links using this option.
    Regardless of where(which controller) your url points to in your project, the action associated with that url will be called.

    So anyway, you can modify your code like this if you want the url to be shown and not a # :

    echo CHtml::ajaxLink('GO', 'http://localhost/index.php?r=user/delete',
     array('type'=>POST), //there are various other options for jquery ajax
     array('href'=>'http://localhost/index.php?r=user/delete'));
    

    To make better ajax links i would suggest going through jquery’s ajax documentation. There is an option for a success function, that you can use to let the user know that the operation was completed.

    Hope this helps, don’t hesitate to leave comments if i haven’t answered your question completely.

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

Sidebar

Related Questions

There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:
I need to get a range of pages using AJAX and put them into
I'm using PUT and DELETE more and more w/ my ajax work and wanted
I am using the jQuery $.ajax() function. I have put this into a parent
I am using the following code to send a user id when the button
Via SWFobject and AJAX I put in a video to a certain <div> .
I've projected an Intranet Ajax application and I want put it in a full
Below is my $.ajax call, how do I put a selects (multiple) selected values
Put it another way: what code have you written that cannot fail. I'm interested
so I've watched http://railscasts.com/episodes/43-ajax-with-rjs but I have a question: In my view I have

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.