0

JSFIDDLE for testing http://jsfiddle.net/8dw09y59/

Hey guys, I've tried everything.. Could someone please explain why i continue to get the "uncaught referenceerror: summonerLookUp is undefined"

I've tried switching the function to windows.summonerLookUp = function() { , but thats hasn't changed anything either. I've tried loading them within , within I've tried loading it at the end of the document, but i get the error "In XHTML 1.0 Transitional the tag cannot contain a tag ." is anyone able to explain whats going on here?

This is my index.js

function SummonerLookUp() {

var SumName
SumName = $("#SumInput").val();

if(SumName !== "") {

$.ajax({

url: 'https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/' + SumName + '?api_key=',
    type: 'GET',
    dataType: 'json',
    data: {

    },
 success: function (json) {
        var SUMMONER_NAME_NOSPACES = SumName.replace(" ", "");

        SUMMONER_NAME_NOSPACES = SUMMONER_NAME_NOSPACES.toLowerCase().trim();

        summonerLevel = json[SUMMONER_NAME_NOSPACES].summonerLevel;
        summonerID = json[SUMMONER_NAME_NOSPACES].id;

        document.getElementById("sLevel").innerHTML = summonerLevel;
        document.getElementById("sID").innerHTML = summonerID;

    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert("error getting Summoner data!");
    }
});

} else {} }

and my index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>LoLStats.GG</title>
<script language="javascript" type="text/javascript" src="../Javascript/index.js"></script>
</head>

<body>
Summoner Name
<br />
<input id="SumInput" />
<button onclick="summonerLookUp()">Click me</button>
<br />
<br />Summoner Level: <span id="sLevel"></span>

<br />Summoner ID: <span id="sID"></span>

</body>


</html>
3
  • 1
    Because your onclick is summonerLookUp with a lowercase s and your javascript is SummonerLookUp with a capital S Commented Jul 9, 2015 at 20:51
  • 1
    summonerLookUp != SummonerLookUp Just a caps issue Commented Jul 9, 2015 at 20:51
  • Good point :) Will update Commented Jul 9, 2015 at 20:56

2 Answers 2

2

The function SummonerLookUp is being called as summonerLookUp, javascript is case sensitive

Change

function SummonerLookUp() {

To

function summonerLookUp() {
Sign up to request clarification or add additional context in comments.

3 Comments

I'd go the other way around and change the function name to summonerLookUp to follow standard javascript naming conventions
@BhavO i wish you knew how stupid i feel right now haha
Glad to help, mistakes happen, use the console output to see the errors, good luck.
1

JavaScript is case-sensitive. You named the function SummonerLookUp, but then you're trying to call summonerLookUp. Make them match.

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.