Using jquery from local file work only if work connection to internet
I have local library jquery
<script src="/js/jquery.js" type="text/javascript"></script>
i have ajax request
.post('/default/AjaxAsinc/addnew',{'new':$("#name").val()},function(data){
for(var i;i< data.length.i++)
{
}
},'json');
But it work only if connection to internet is active if connection is down
i see开发者_运维知识库 next exception
data is null
[Break on this error] for(var i=0;i<data.length;i++)
Any idea solve this problem ?
PS Browser Firefox not fetch any data from another site all data to responce is local
From looking at your code, the only place data is referenced is in your callback function "the response of your $.post().
I would check that data is valid and contains data before trying to for() loop through it.
$.post('/default/AjaxAsinc/addnew', {'new':$("#name").val()}, function(data) {
if(data !== undefined && data.length > 0) {
for(var i=0;i< data.length.i++) {
}
}
},'json');
精彩评论