0

I'm not primarily JS, so I may be making a stupid here, apologies if that is the case.

In the code:

function loadeightoheightclap("http://thomasmurphydesign.com/dubstepclap.wav") {
var request = new XMLHttpRequest();
request.open('GET', "http://thomasmurphydesign.com/dubstepclap.wav", true);
request.responseType = 'arraybuffer';

request.onload = function() {
    context.decodeAudioData(request.response, function(buffer) {
        eightoheightclapbuffer = buffer;
    }, onError);
}
request.send();
}

The URL in that's the argument of function loadeightoheightclap is throwing a syntax error. It's a valid URL, and there's no syntax error when that URL is used as an argument of request.open later.

How do I need to modify the argument to remove the error?

1

1 Answer 1

2

Functions definitions should take a parameter name, not an actual value:

function loadeightoheightclap(url) { /* ... */ }

Your should only use a value when calling it:

loadeightoheightclap("http://thomasmurphydesign.com/dubstepclap.wav");

Then you can use that value by name inside the function:

request.open('GET', url, true);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you bfavaretto. I was mistaking the code in the tutorial I was working through for a placeholder in which I was to paste the URL.

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.