I have a hard time with $.ajax(). I have this HTML page :
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<form name="gettr" id="gettr">
<input type="hidden" name="lang" value="ro">
<input type="text" name="tickkey" id="tickkey" value="">
<br>
<input type="submit" value="Send" id="submit">
<input type="reset" value="Cancel" onclick="$("#hereinfo").html("");">
</form>
</body>
</html>
And the script :
$("#gettr").submit(function() {
var url = "handler.php";
$.ajax({
type: "GET",
url: url,
dataType: "application/json",
data: $("#gettr").serialize(), // serializes the form's elements.
success: function(data) {
alert('Done');
}
});
return false;
});
I'm running the script locally now, and my problem is that the script doesn't do anything.When I click on send button it just adds ?lang=ro&tickkey=value_inputed_in_the_form
at the end of the url in the address bar.What should I do so I can store the JSON returned by the server in a variable?
Thank you!