0

what does

script.setAttribute('src', '/json?callback=loadJsonPhotos');

JavaScript code mean?

3 Answers 3

4

That's a little snippet of code to set the src (source) attribute of a Javascript include tag to /json?callback=loadJsonPhotos. Once that line of code runs, the browser will fetch the data from that URL and execute the script that returns. The data that script returns will be wrapped in a function like so:

loadJsonPhotos({data: "blah"});

All you need to do to use that data is write a function called loadJsonPhotos that will be called once the data has loaded.

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

Comments

0

It sets the src attribute of the html for script to /json?callback=loadJsonPhotos

Comments

0

This script is equivalent to write the following html code:

<script src="/json?callback=loadJsonPhotos"></script>

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.