Friday, July 17, 2015

Class.each with ajax for each

$('.routeInfo').each(function(){
    // 
    fid = $(this).attr("fid");
    id = $(this).attr("id");
    uniqueID = $(this).attr("uniqueID");
    $.ajax({
            url: '/route.php',
            type: 'GET',
            data: { fid: fid , user: 'fred' } ,
            success: function (response ) {
                 if(response.length > 5) {
                        $("#" + id).html('ROUTE STATUS: '+response);                   
                                     }  else {
                                     $("#" + id).html('ROUTE STATUS: Not Routed');
                                       }
            },
            error: function () { console.log('ajax error'); }
        });
     });  

No comments: