开发者

Not able to make Ajax call using jquery

开发者 https://www.devze.com 2023-03-03 10:17 出处:网络
I am trying to call a Sample API from my JSP using jQuery Ajax, but I am not getting success. I dont know where am I wrong but even simple html page is not getting loaded.

I am trying to call a Sample API from my JSP using jQuery Ajax, but I am not getting success. I dont know where am I wrong but even simple html page is not getting loaded.

Here is my code.

<%@ page language="java" contentType="text/html; charset=ISO-8开发者_StackOverflow中文版859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Insert title here</title>
    </head>
    <body>
        Hello
        <div id="temp">
            <a href="#" onclick="callGetApplicationDetails();" >Click Here</a>
        </div>
        <script type="text/javascript">
            function callGetApplicationDetails() {
                jQuery.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", function(data) {
                    alert('inside');
                    $.each(data.items, function(i,item) {
                        $("<img/>").attr("src", item.media.m).appendTo("#temp");
                        if ( i == 3 ) return false;
                    });
                });
            }
        </script>
    </body>
</html>


You forgot to load jQuery. Add the following to your <head>.

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
0

精彩评论

暂无评论...
验证码 换一张
取 消