Timeline for JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 23, 2020 at 22:06 | answer | added | ScottUSA | timeline score: -1 | |
May 23, 2020 at 21:31 | comment | added | ScottUSA | RE: /wp-contents/custom-php/votifier.php. I had that initially and it didn't work. So, I tried the full path just as a test. I am still working on it. I have more to post. | |
May 23, 2020 at 12:03 | comment | added | Hannes |
Your url is definitely wrong. You are trying to access a server path instead of an url. $.post("/home/xxxxxxxxxxxx/public_html/wp-content/custom-php/votifier.php", . Can't you just use /wp-contents/custom-php/votifier.php ? If you output something in your PHP file you could check whether or not it is reachable by just entering the full url in your address bar bestlist.com/wp-contents/custom-php/votifier.php
|
|
May 23, 2020 at 2:17 | history | edited | ScottUSA | CC BY-SA 4.0 |
deleted 15 characters in body
|
May 23, 2020 at 1:57 | comment | added | ScottUSA | Yes, got a 404 status code. I can see all my parameters. Cause = xhr for File votifier.php | |
May 23, 2020 at 1:56 | history | edited | ScottUSA | CC BY-SA 4.0 |
added 286 characters in body
|
May 23, 2020 at 1:33 | comment | added | Himad | On the Firefox dev tools, go to network and select the AJAX request that gets sent when you use the button. What's the response status code? No message at all? If the path is wrong then you should at least be getting a 404 status code. | |
May 23, 2020 at 1:30 | comment | added | ScottUSA | okay, I added that to the PHP script and nothing. I know the button is working. So, it has to be the JQuery. I checked page source and I can see my JQuery script in the header and it looks good. I guess I have to learn AJAX for WordPress. | |
May 23, 2020 at 1:14 | comment | added | Himad |
Can you modify the PHP script and add die('Example'); as the first line? If your request is correctly going through you should see the message as the response.
|
|
May 23, 2020 at 1:12 | comment | added | ScottUSA | regarding the AJAX Thanks. About the network tab: I'm using firefox. The WordPress site doesn't show anything, but the network tab for my localhost looks normal. Stats of 200, Method is post, domain is localhost | |
May 23, 2020 at 0:44 | comment | added | Himad |
That's not the correct way to deal with AJAX requests in WordPress. You should hook to the wp_ajax_ action. Anyway, if you're using chrome, what does the network tab show about that request response?
|
|
May 23, 2020 at 0:41 | review | First posts | |||
May 23, 2020 at 2:45 | |||||
May 23, 2020 at 0:39 | history | asked | ScottUSA | CC BY-SA 4.0 |