I want to use jquery to implement ajax response from perl script on the server.But when I use such code, I got nothing. I can get the result from the url in a browser, so I don’t know where is wrong.
$(document).ready(function(){
$("button").click(function(){
$.ajax({
'type': 'GET',
'url': 'http://XXXX/cgi-bin/XXX.pl?title=dd',
'async': true,
'success': function(data) {
alert(data);
}
});
});
});
If url field contain
http://server.domain/and if you try to access a server from a webpage located elswhere than http://server.domain/ (like in your desktop for sample, accessed viafile:///), probably you need to add a fieldAccess-control-allow-origin: *in the header sent by your perl CGI:Take care of security considerations…