1

How can I modify this:

/services/type/single_dwelling/

to this:

/ajax/services/single_dwelling/development

Currently I have:

linkUrl = $(this).attr("href").replace(/(\/(services)\/)/,"$1ajax/");

Which outputs:

/services/ajax/type/single_dwelling/

I'm a little confused.

1
  • Nicely formatted question. Short, sweet, informative and to the point. Commented Oct 29, 2009 at 4:04

2 Answers 2

6

Looking carefully I see you want to prepend '/ajax', remove '/type' from the original url, and append 'development':

var linkUrl = '/ajax' + $(this).attr("href").replace('type/','') + 'development';

That will output "/ajax/services/single_dwelling/development" using your test string.

Sign up to request clarification or add additional context in comments.

Comments

1

Try:

linkUrl = "/ajax" + $(this).attr("href").replace("/type", "") + "development";

Comments

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.