0

I think it must be easy, but still, can not figure out how to solve this. So I've got a variable that contains a URL:

> var siteurl = 'http://my-site.com';

All I need is to add "siteurl" variable into another url before /load.php

function load(){
    $.getJSON('/load.php', function(data) {
        appendComments(data);
    });
}

So that the ultimate url was

http://my-site.com/load.php

2

1 Answer 1

3

You can merge a string variable with another string using +

function load(){
    var siteurl = 'http://my-site.com';
    var url = siteurl + '/load.php';
    $.getJSON(url, function(data) {
        appendComments(data);
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.