call the function in ajax

Well, you need to debug your code step-by-step.

  1. First of all, try to var_dump($galleryDetails);, and see if it returns what you want.

  2. If it does then check you AJAX function, but try to simplify your received data. Comment everything in you searchAuction.php file and JUST echo json_encode(['type'=>'3']); this code. In the AJAX function JUST alert(data['type']); in you success method and comment everything else inside of it. This way you will know if your AJAX call works correctly and receives valid data. If it does->

  3. Uncomment your $galleryDetails code and adjust your JSON data. Uncomment your code in the AJAX function and try to run it to receive what you want.

Don't try to debug the whole code. It is too complicated. Make sure that every single block of your code works and then join these working blocks step by step.