pollux1er
pollux1er

Reputation: 5919

Codeigniter base url include port generated randomly

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 ?

Upvotes: 2

Views: 961

Answers (1)

Santosh Satapathy
Santosh Satapathy

Reputation: 174

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.

Upvotes: 1

Related Questions