代码不起作用

This is the code:

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function nameNotAva()
{
alert("Name already exists.");
//some code
}

function nameCheck() 
{
var username = document.getElementById('uname').value;
var url = "http://rscript.org/lookup.php?type=namecheck&name=";
var curl = url + username;
 $.ajax({
     url : curl,
     type : 'GET',
     success : function(urlOutput){ 
             if(urlOutput.contains('NAMECHECK: NOTAVALIBLE')){ 
                  nameNotAva(); 
               } 
          }
   });
}
</script>
</head>
<body>
<input class="textBox" id="uname" type="text" maxlength="15" required/>
<input type="button" onclick="nameCheck()" value="Submit">
</body>
</html>

The problem is there in the $.ajax part. I know this because when i put alert(curl); just before the ajax part, it displays the correct URL. If you want the complete info that what i am trying to do then goto- How to check output of a created URL?

I am using jquery library of the latest version.

You haven't included the jQuery library so $ is undefined and the script will error on the Ajax part.

In general, if you have a problem with some JavaScript: Open the JS console in your browser and pay attention to any error messages.

Update after comments suggest that the code in the question was incomplete:

This is the library i am using- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js" type="text/javascript" />

Script elements are not defined as empty. The end tag is required.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js">
</script>

http://jsfiddle.net/ksJEj/

Change the input type:

<input type="submit" value="Submit"/>

include this in your <head></head> tags:

HTML

<script type="text/javascript" src="ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

and this too:

HTML/JavaScript

<script type="text/javascript">
$(document).ready(function{
    function nameNotAva() {
        alert("Name already exists.");
        //some code
    }

    $('input[type="submit"]').click(function (event) {
        event.preventDefault();
        var username = $('#uname').val();
        $.get("http://rscript.org/lookup.php", {
            'type': 'namecheck',
            'name': username
        }, function (urlOutput) {
            if ($(urlOutput).contains('NAMECHECK: NOTAVALIBLE') == true) nameNotAva();
                else alert("woohoo");
        });
    });
});
</script>