Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Query Amazon with javascript

Posted on 2014-07-16
10
Medium Priority
?
201 Views
Last Modified: 2014-08-14
ok so I have been banging my head over this for sometime now and I think it is time to get you "Experts" involved.
I am trying to query amazon using JavaScript with the following code.  initially I am only trying to retrieve one record using its ASIN, but would like to have it search more than one  in the future.
The issue I am encountering is that although the initial call was successful upon running again the page renders and it is blank.  I am assuming that it is due to the signature but cannot figure out how to overcome.

Any help would be great.

<script src="jquery.js"></script>
<script src="jquery.xdomainajax.js"></script>

<script>

$(document).ready(function(){

  
$.ajax({
    url: 'http://ecs.amazonaws.com/onca/xml?'+
	'AWSAccessKeyId=AKIAIRINHF6V5xxxxxxxx'+
	'&AssociateTag=xxxxxxxxxx+
	'&Keywords=B004C5P522'+
	'&Operation=ItemSearch'+
	'&SearchIndex=All'+
	'&Service=AWSECommerceService'+
	'&Timestamp=2014-07-14T17%3A47%3A17.000Z'+
	'&Signature=eiVgRbMPlZwMau%XXXXXXXXXXXXXXX3D',
    type: 'GET',
    dataType: "xml",
    success: function(res) {
        console.log(res.responseText);

        var xml = $.parseXML(res.responseText);
        var $tmp = $( xml );
        var tmp2 = $tmp.find( "head" );
        $('.container').append(tmp2.text()+'<br>');


    },
	error: function(){
		alert('failed')
	}
});


});
</script>

</body>
</html>

Open in new window

0
Comment
Question by:jriver12
  • 5
  • 3
9 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 40200770
could you paste what you get with line 22?
0
 

Author Comment

by:jriver12
ID: 40200948
I don't get anything. Just blank screen.
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40200960
unless some condition Ajax call are not allowed cross domain/protocol
that mean than your page residing on www.yourdomain.com CAN'T get data from ecs.amazonaws.com

you need to use a server side language to get the content and send it back to your page
1 - so your page call your server side function and ask him to dowload the right content
2 - your server get the content from amazon : ecs.amazonaws.com/onca/
3 - your server send the content requested to/by your page
0
Cyber Threats to Small Businesses (Part 2)

The evolving cybersecurity landscape presents SMBs with a host of new threats to their clients, their data, and their bottom line. In part 2 of this blog series, learn three quick processes Webroot’s CISO, Gary Hayslip, recommends to help small businesses beat modern threats.

 

Author Comment

by:jriver12
ID: 40200969
I will check in am and update on condition.

thanks.
0
 

Author Comment

by:jriver12
ID: 40209762
Well have had no luck. I have been trying to do it with coldfusion.
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40210390
so ? you did not find any coldfusion proxy code? I posted one some months ago for a similar question
0
 

Author Comment

by:jriver12
ID: 40211474
no I have not, at least any that work.  Do you still have that code you posted?  If possible can I take a look?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40260364
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 

Author Closing Comment

by:jriver12
ID: 40260365
Thanks for the push in the right direction. unfortunately the new API would not render the information we needed.  

thanks again.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question