views:

45

answers:

1

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

+1  A: 

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');
Paul Dragoonis
the data is empty.10 min before i see answer user "Sac" he delete self answer ?
alexandr