help with header... or something else?

  • Hello,

    here goes mine trouble...

    i have on server some images

    i make ajax call on my action.php wich looks like this:

    <?php
      header('Access-Control-Allow-Origin: *');
      $imagesDir = '';
      $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
      echo json_encode($images, JSON_UNESCAPED_UNICODE);
    ?>[/code:20bikun7]
    
    it works but i have local characters problems.
    when i set header to:
    
    [code:20bikun7]<?php
      header('Content-type: text/html; charset=UTF-8');
      $imagesDir = '';
      $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
      echo json_encode($images, JSON_UNESCAPED_UNICODE);
    ?>[/code:20bikun7]
    i manage to get rid of characters problem but it works only in NW.js and i have no ajax responce in any major browser... 
    
    any idea how to fix this?
  • My guess, you need also the 'Access-Control-Allow-Origin' in your 2nd php-script:

    <?php
      header('Access-Control-Allow-Origin: *');
      header('Content-type: text/html; charset=UTF-8');
      $imagesDir = '';
      $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
      echo json_encode($images, JSON_UNESCAPED_UNICODE);
    ?>[/code:5mjr5vv1]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thanx for the help... but with this i have sort of semi solution where i actually get immages (i get their data, name etc.) but i dont see them.... they are all black!?

    im confused...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)