-5

Is there any way I can call a PHP function from jQuery? I have a .js file and a .php file.

I have a jQuery event applied on a button click. Now I want to set a condition on what happens next when the button is clicked depending on whether a user is logged in or not. Is there any way I can do this from my .js file ?

2

3 Answers 3

0

You can call any php file by the common HTTP methods, e.g. GET and POST. What you might be looking for is AJAX. Google the term, and also look into jQuery for a simplified approach.

Sign up to request clarification or add additional context in comments.

Comments

0

You can send it to a php file with ajax and use your php file to check if the user's logged in. Then you can send a response back to your js file to see which event you should trigger

Comments

0

Technically, yes. But why would you want to in this case? My suggestion is to look into storing values in cookies, since both PHP and JS will have access to them.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.