I work with one project module, where I want to get a converted price from Google finance converter based on the currency code and amount. Here is my code:
$('.actual-price').tooltip({
content: function(callback) {
var url = 'https://www.google.com/finance/converter?a=25&from=USD&to=AMD';
$.get(url, {}, function(data) {
callback(data);
});
},
open: function(event, ui) {
var $id = $(ui.tooltip).attr('id');
$('div.ui-tooltip').not('#' + $id).remove();
},
close: function(event, ui) {
$('.ui - tooltip').hide();
}
});
This gives me an error:
XMLHttpRequest cannot load https://www.google.com/finance/converter?a=25&from=USD&to=AED. no The header header Access-Control-Allow-Origin is present in the requested resource. The origin is http://mytestsite.comtherefore not allowed access.
I tried the following ways to solve it, but nothing seems to work for me!
First: Added Access-Control-Allow-Originto web configuration.
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
Second: using jsonp data type:
dataType: "jsonp",
And already mentioned the following posts:
No header "Access-Control-Allow-Origin" is present on the requested resource "
"Access-Control-Allow-Origin"
"Access-Control-Allow-Origin" . Origin '...'
"Access-Control-Allow-Origin" "
: localhost, , !