0

below code working fine but I need to append option1 in href,

 $(document).ready(function () {
        $("#head_drop .dd-option").click(function () {
            var option = $('.dd-option-value',this).attr('value');
            var option1 = $('.dd-option-text',this).text();
           // alert(option1);
            $.ajax({
                type: 'get',
                url: '<?php echo $this->getBaseUrl();?>categories/index/city/',
                data: {option: option},
                success: function(data) {
                    $(location).attr('href',"<?php echo $this->getBaseUrl()?>");
                }
            });
        });
    });

now its return http://example.com/

I want like http://example.com/option1

I tried $(location).attr('href',"<?php echo $this->getBaseUrl()?>"option1); but failed to get, Thanks...

1
  • 1
    Try this: $(location).attr('href',"<?php echo $this->getBaseUrl()?>/" + option1); Commented Feb 25, 2015 at 13:18

2 Answers 2

5

If option1 is a variable all you need is to concatenate with a + -

$(location).attr('href',"<?php echo $this->getBaseUrl()?>" + option1)
Sign up to request clarification or add additional context in comments.

4 Comments

Jay definitely deserves a double espresso ;-)
That would work for me this morning @Fred-ii- Morning Ralph (side note: we could always do a radio show, the Ralph & Sam show. Yes, I am being rather random this morning.)
@JayBlanchard Mornin' Sam - We could then switch roles with a quick flip of the zipper
And run the "don't use mysql_*" or "parameterize those queries" announcements at the top of every hour.
0

You have your " at the wrong place, it should read:

$(location).attr('href',"<?php echo $this->getBaseUrl()?>option1");

2 Comments

Option1 is a variable, so if you put it inside the quotes, it will not work as a variable anymore.
Ah, my bad, the OP stated he wanted this URL: http://example.com/option1, I didn't notice it should refer to a variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.