Jquery Ajax /GET method nothing happend when success
get, http, jquery
Solution
I have implemented something you want to. Here is the code. And it works completely fine.
Hope it helps you.
<html>
<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#submit").click(function(){
$.ajax({
type: 'GET',
url: "http://localhost/page1.html",
success:function(data){
alert(data);
}
});
return false;
});
});
</script>
</head>
<body>
<input type="button" id="submit" value="submit" />
</body>
</html>
Problem
I have a RESTful web service which runs on Glassfish Application Server. When I invoke the web services with /GET HTTP method on cURL, stored entries are fetched to console. I want to make a jQuery REST client - when I click the button, it must alert me to the returned JSON or XML entries. But in success method, nothing happened. My html page looks like below. ``` <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Başlıksız Belge</title> </head> <body> <input type="submit" name="kaydet" id="kaydet" value="Kaydet" /> <script type="text/javascript" src="jquery-1.7.2.js"></script> <script type="text/javascript"> var restURL="http://localhost:43842/KodcuComRESTful/kodcuRS/yazilar"; $('#kaydet').click(function(){ $.ajax({ type: 'GET', url: restURL, dataType:"json", success: renderList, }); return false; }); function renderList(data) { alert(data); } </script> </body> </html> ``` When I observed the request and response in Live HTTP headers program, it seems everything is OK. What is the problem?