I'm working with one project module, where I want to get converted price from Google finance converter based on from 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();
}
});
It gives me an error:
XMLHttpRequest cannot load
https://www.google.com/finance/converter?a=25&from=USD&to=AED
. No 'Access-Control-Allow-Origin' header is present on the requested resource. Originhttp://mytestsite.com
is therefore not allowed access.
I've tried following ways to solve it, but seems like nothing works for me!
First:
Added Access-Control-Allow-Origin
to the web config.
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
Second: Using datatype jsonp:
dataType: "jsonp",
And already referred following posts:
“No 'Access-Control-Allow-Origin' header is present on the requested resource”
No 'Access-Control-Allow-Origin' header is present on the requested resource error
“No 'Access-Control-Allow-Origin' header is present on the requested resource”
Side: It's working with my localhost, but when I try with another domain, it's give me an error!