You can’t directly “call” a PHP function from JavaScript without refreshing, because PHP runs on the server and JavaScript runs in the browser.