2

I am using Codeigniter 3 to build an application with PHP Desktop and I am trying to get the base url to execute an ajax script in javascript.

$.get( "<?php echo base_url("print_ticket_associate.php"); ?>", { pin: pin, dash : "no", entree : "0", dessert : "0", repas :"1", badge : badge } );

Unfortunately, my configuration include random port on http and I need to include this to my base url on codeigniter. This means I can not set it in configuration.

Assuming the page I am trying to execute the script from is : login/match, base url for for codeigniter will be http://localhost/login/match. Which means it is not possible to paste the port after the string. I want to access http://localhost:randomPort/print_ticket_associate.php

Is there a way to get that port at a specific time in codeigniter page ?

pollux1er
  • 5,372
  • 5
  • 37
  • 36

1 Answers1

1

I had the same issue. But i got the solution. Open the settings.json file and change the server port to a fixed port as follows...

"web_server": {
        "listen_on": ["127.0.0.1", 8888],
       ..........
}

and in codeigniters config.php set the

$config['base_url'] = 'http://localhost:8888/';

Note : You can use any number in place of 8888. Happy coding.

  • This is the solution I finally adopted. Thanks – pollux1er Aug 18 '18 at 07:06
  • Welcome. But i got a little better solution. Just use the port 80. Which does not require to use in the base url. Ex. The setting is http://127.0.0.1 with port as 80, then the base url will be only the http://127.0.0.1 or http://localhost/ which doesnot required the port as 80 is default. Thanks – Santosh Satapathy Aug 19 '18 at 10:00
  • Its not, many users have there own server running on port 127.0.0.1 80. – Esocoder Apr 13 '21 at 10:29