Reputation: 1179
I am trying to run below given code.It is working properly in IE browser but in other browser it is not working.
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4 /jquery.min.js'></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button1").click(function(){
alert("1");
$.ajax({url:"file://///30.170.12.75/Shared/a.html"
,success:function(result) {$("#div1").html(result);}
,error: function(result) {alert("2");}
});
});
});
<script>
As i know jquery api provide us browser compatibility also but it is not working any of other browser.
Please Let me know the reason so that in future i will be taking care of them.
Upvotes: 0
Views: 191
Reputation: 2271
You're using file://
protocol and most browsers don't allow access to this if the source document is not server with the file://
protocol.
For ajax requests, most browsers will block the requests if the destination protocol is a file://
protocol. However, IE doesn't seems to behave like this and still allow the request to finish.
If you're using Chrome, you can change this by starting Chrome with a --allow-file-access-from-files
flag.
(Is it really to be file://
and not http://
or other things?)
Upvotes: 2