I have been messing around with this for about an hour now and changed a lot so there may be some stupid errors that I am not picking up :/
Dylan
@dhcodes
well i think it may be the s in https
but even if i remove it, it calls the https page
so idk, still messing with it
Will Kempster
@kempsterrrr
I had that issue with the weather App and ended up using this URL proxy service - https://crossorigin.me/
But no matter what I do I can't make this one work. I even tried copying in code from tutorials (forgive me) just too see if I as going mad but it was still throwing the same error
Dylan
@dhcodes
@WilliamFace i just used that prepend and it did work
change your success function to console.log(request)
and you will see an XML return in the console
@WilliamFace fwiw, I find that jquery.getJSON is an easier approach for apis or AJAX even may be easier than XML
but that could be because I don't know how to parse XML
if you want, I can fork your project
and send a link
Will Kempster
@kempsterrrr
If you could, I'd be really grateful
Just added the s to http and appended with https://crossorigin.me and the error has gone but the API is still not being called and not adding the response text to searchObj
@dhcodes maybe I am just trying to be too clever no using get.JSON! I did the weather app with it and then re-wrote it for practice with vanilla js, thought I could go ahead and do this one in vanilla but obviosuly not :smile:
@dhcodes thanks!! Finally it's called the API :smile: for someone reason though it wont parse the responseText to JSON when using JSON.prase(request.responseText)
CamperBot
@camperbot
williamface sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
Which is really weird as the information is clearly there in responseText
Dylan
@dhcodes
@WilliamFace i think it's because your response is coming back as xml and not json
Will Kempster
@kempsterrrr
@dhcodes ahhhhhhh that makes sense ! The error it is throwing up now is 'unexpected / at position blah blah' which must be the / at the start of the XML
Dylan
@dhcodes
yeah, i'm not sure there's a good way to convert it from xml though
idk why it isn't giving json since you request that in the format
Will Kempster
@kempsterrrr
yeah it's really weird, I actually think it is returning JSON but /**/( is appended to the start of the file so you can't use JSON.parse
never seen that before
Just tried it on my weather app and the /**/( is not there
Stephen James
@sjames1958gm
@WilliamFace Can you save your codepen page, I'd like to take a look at the latest.
Dylan
@dhcodes
@WilliamFace yeah but if you console.log(request.responseText) it is definitely xml