IT Monkey:   Click Here to Help Me Build the Agenda for Upcoming Cireson Webinars!

API Returning Invalid Character

Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
edited September 2017 in Analyst Portal
I'm trying to get the users phone number from the API. I have the following but when I run it I'm just getting 'Invalid Character'

$.getJSON('/search/getObjectProperties', {"id": session.user.Id}) ,function(data) { var obj=jQuery.parseJSON(data); console.log(obj.BusinessPhone); });

Any ideas?

Answers

  • Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Advanced IT Monkey ✭✭✭
    Unintuitively getJSON() does not return a JSON object, and your parseJSON() therefore fails to parse it. Instead, you get a jqXHR object, which you can just treat as a normal JS object, so you can do data.BusinessPhone, without parsing it first.
  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    Excellent! Now I just need to try and shoehorn this into one of my other scripts so I can inject the businessphone into another field
Sign In or Register to comment.