0

I am new in jQuery. But what I found is it is very easy to use with any Javascript functions.

What I am trying is to achieve -

http://www.w3schools.com/jquery/demo_ajax_json.js

this or this

https://www.googleapis.com/calendar/v3/calendars/mnjusq8qt3kh847kge772s9fmk%40group.calendar.google.com/events?singleEvents=true&key=AIzaSyD28KypP-wTD-AKZVECKL0WsxoXhJiYbys

address's JSON data in my page with Javascript with help of jQUery.

Page Content is simple JSON data-

{ 
  "firstName": "John",
  "lastName": "Doe",
  "age": 25
}

What I have done in jQuery is-

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

<script>
    $(document).ready(function ()
    {
        $.ajax(
        {
            type: 'GET',
            url: 'http://www.w3schools.com/jquery/demo_ajax_json.js',
            dataType: 'jsonp',
            success: function (data)
            {
                console.log(data);
                $.each(data, function(index, element)
                {
                    console.log(index + element);
                });
            },
            error:function(e)
            {
                console.log(e.message);
            }
        });
    });
</script>

And What I am getting in every time is -

In Chrome-

Uncaught SyntaxError: Unexpected token :

In Firefox-

SyntaxError: missing ; before statement "firstName": "John",

I have tried many times and searced everywhere for its solutions.

But I can't get a proper solution.

Can anyone please help me?

Thanks in advance for helping.

Community
  • 1
  • 1
Abrar Jahin
  • 13,970
  • 24
  • 112
  • 161

0 Answers0