1

Below is my method

function getCurrentUserName() 
{
    $.ajax({ 
    type: "GET",
    url: "http://localhost:8099/rest/prototype/1/space/ds",
    crossDomain:true,
    dataType: "jsonp",  
    success: function(resp){  
        alert("Server said123:\n '" + resp.name + "'");  
        },
    error:function(e){
    alert("Error"+e)
    }
    });
    });
}

I am calling this on a button click , I do not see any alert , when i type the url on the browser I get the response in xml .but i do not get the response in the script. Can someone please help me with this ? Am i missing something here ? Thanks :)

1 Answers1

0

Looks like a JSON parse error.

Try with the json instead of jsonp

function getCurrentUserName() 
{
    $.ajax({ 
    type: "GET",
    url: "http://localhost:8099/rest/prototype/1/space/ds",
    crossDomain:true,
    dataType: "json",  
    success: function(resp){  
        alert("Server said123:\n '" + resp.name + "'");  
        },
    error:function(e){
    alert("Error"+e)
    }
    });
    });
}
Nirmal
  • 1,223
  • 18
  • 32
  • I get the same error .. the data returned by the rest call is in xml format . I need it in Json . I am also trying the below code '$.ajax({ type: 'GET', url: "http://localhost:8099/rest/prototype/1/space/ds", data: {}, dataType: "xml", success: function (xml){ var clientid = $(xml).find('avatarUrl').first().text(); alert(""+clientid); } });' – user3559178 Apr 22 '14 at 07:31