question

xylophoton avatar image
0 Likes"
xylophoton asked

Very basic javascript XMLHttpRequest, can't understand how this is ever going to work.

I am not particularly skilled at writing javascript as I'm sure many of you will be able to guess, however there is no minimum level of proficiency for joining the developer's program so I am going to go ahead and ask my stupid questions. I am struggling to figure out how to actually implement a call to the API in any actually useful manner. Is there something wrong with this code? var xmlhttp = new XMLHttpRequest(); var xml = '[REQUEST XML]'; var url = ' https://api.ebay.com/ws/api.dll'; xmlhttp.open("GET", url); xmlhttp.setRequestHeader('Content-Type', 'text/xml'); xmlhttp.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', '895'); xmlhttp.setRequestHeader('X-EBAY-API-DEV-NAME', 'XXXXXXXXXX'); xmlhttp.setRequestHeader('X-EBAY-API-APP-NAME', 'XXXXXXXXXX'); xmlhttp.setRequestHeader('X-EBAY-API-CERT-NAME', 'XXXXXXXXXX'); xmlhttp.setRequestHeader('X-EBAY-API-SITEID', '3'); xmlhttp.setRequestHeader('X-EBAY-API-CALL-NAME', 'GetSellingManagerSoldListings'); xmlhttp.send(xml); xmlDoc=xmlhttp.responseXML; Well, for one, if I can just partially answer my own question here, it is making a cross-origin request, however I am struggling to see how this is ever not going to be an issue... and if it IS always going to be an issue, it seems like this severely limits the usefulness of javascript here, despite there being a section seemingly devoted to javascript on this site. What am I missing? I'm sure the answer is "a lot", but if someone could summarise, I would be grateful.
xmljavascriptxmlhttprequestcross-origin
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
helios825 avatar image
0 Likes"
helios825 answered
I don't program in JS, so I can't help you with that. But I did happen to notice that you're experimenting with a call to the Trading API -- something that's not exactly meant for beginners. Unless you explicitly need to the use the GetSellingManagerSoldListings call, I recommend you start out with a non-Trading API call like in the Finding API. The FindingAPI is much easier to call. Maybe start with [getVersion][1] just to retrieve some basic info and validate your JS programming strategy. [1]: http://developer.ebay.com/DevZone/finding/CallRef/getVersion.html
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.