Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2013 Daniel Holm <d.holmen@gmail.com>
- * Victor Thompson <victor.thompson@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- // Custom debug funtion that's easier to shut off
- function customdebug(text) {
- var debug = "1"; // set to "0" for not debugging
- if (debug === "1") {
- console.debug("Debug: "+text);
- }
- }
- function request() {
- var URL = "https://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=Kiss&api_key=07c14de06e622165b5b4d55deb85f4da";
- var xhr = new XMLHttpRequest(); // create new XMLHttpRequest
- var encodedURL = encodeURIComponent(URL); // Make sure whatever you post is URI encoded
- xhr.open(TYPE, encodedURL, true); // only async supported
- xhr.send(); // send the data
- xhr.setRequestHeader("User-Agent", "Music-App/0.3");
- xhr.setRequestHeader('Content-Type', 'text/xml');
- // did it work?
- if (xhr.readyState==4 && xhr.status === 200) {
- customdebug("Response = " + xhr.responseText);
- }
- else {
- // This is very handy for finding out why your web service won't talk to you
- customdebug("Status: " + xhr.status + ", Status Text: " + xhr.statusText + ", Ready state: "+xhr.readyState);
- }
- return xhr.responseText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement