I use Sinatra to host a simple service. This is all my application:
require 'sinatra'
get '/hello' do
'Hello world!'
end
Then I have one html file in my directory ./publicthat is trying to execute a GET request in my service:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function(event) {
$.get("/hello", function() { alert("first success"); })
.success(function() { alert("second success"); })
.error(function(jqXHR) { alert("error: " + jqXHR); });
})
});
</script>
</head>
<body>
<a href="">Link</a>
</body>
</html>
When I click on the link in my HTML page, in my journal log, I see the following:
0: 0: 0: 0: 0: 0: 0: 1% 0 - - [16 / Feb / 2011 10:37:42] "GET / hello HTTP / 1.1" 200 12 0.0030
localhost - - [16 / Feb / 2011: 10: 37: 42 CST] "GET / hello HTTP / 1.1" 200 12
Referer → / hello
Which seems good, but no matter how I try to change the settings, I can only get the error callback - never succeed.
:
1) ?
2) ? , , , .
!