Get gallery in loop through ajax

Have you tried passing $pid instead of using get_the_ID()?

if (get_post_gallery($pid)) :
   $gallery = get_post_gallery($pid, false);
endif;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)