7
When I write Ajax with Cakephp’s Jshelper, I write something like this
$this->Js->get('#searchCity')->event(
'click', $this->Js->request(
'http://api.geonames.org/searchJSON', array(
'async' => true,
'dataExpression' => true,
'method' => 'GET',
'data' => "{}",
'dataType' => 'JSON',
'success' => ""
)
)
);
the output is more or less like this
$(document).ready(function() {
$("#searchCity").bind("click", function(event) {
$.ajax({async: true, data: {},
dataType: "JSON", success: function(data, textStatus) {
}, type: "GET", url: "http:\/\/api.geonames.org\/searchJSON"});
return false;
});
});
Apparently, the . bind() function does not work in Internet Explorer, and I read that I can use . on() to replace it.
The question is, can I change these methods without having to tamper with Cakephp’s core or is there some smarter solution?
What version of your cakephp?
– Erlon Charles
tried "onclick" instead of "click"?
– Paulo Roberto Rosa
I think I figured out what’s going on, and it has nothing to do with . bind(). I’m trying to request an external url, and IE is blocking me because of the Same origin policy. Is there any way around this??
– Heverton Coneglian de Freitas
Yes, please ask another question, with Ajax Cross Domain. Just to keep the site "organized," choose an answer like the one you think is right.
– Leandro Amorim