简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM