This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

After Integration the Add Comment button does not work
#1

I'm trying to see if I can integrate into the Blog, www.bludit.com, by creating a plugin for it.

Although the Comments form appears and can be populated, nothing happens when the Add Comment or Preview buttons are pressed.

The Javascript code that supports the button is in a script tag and I've not found a way to debug it.
I'm guessing that the Ajax code is not working.

I know that Commentics works with a very simple installation and using the example1.php file.

Can anyone suggest what the problem might be, or a method to debug the event from these buttons

Thx
Reply
#2

The best thing would be to open your browser's developer tools (F12) and look for any JavaScript errors, look to see if the Ajax request is firing, whether the Ajax request is going to the right URL and what it returns.

If you share a link to the page you're integrating Commentics into then I don't mind checking the above for you.

Have you completed the interview?
Reply
#3

(19-May-2017, 07:55 PM)Steven Wrote:  The best thing would be to open your browser's developer tools (F12) and look for any JavaScript errors, look to see if the Ajax request is firing, whether the Ajax request is going to the right URL and what it returns.

If you share a link to the page you're integrating Commentics into then I don't mind checking the above for you.

I have the exact same thing happening. New install, went without a single glitch. All systems green. I've logged in as admin and cleaned up all the Dashboard tasks successfully and did a bit of disabling form fields I don't need to see. The add comment form displays perfectly. But Add and Preview buttons don't do anything. Here's my error message:

path.../frontend/index.php?route=main/form/submit Failed to load resource: the server responded with a status of 500 (Internal Server Error) 


It looks like the path to 'submit' should be: controller/main/form  Although 'form' is form.php and not a directory. What do I need to edit to fix this? Or is something else wrong as well? 

Thank you, Michael Wassil
Reply
#4

Hi Michael,

The path looks fine to me.

With a 500 error you'll need to check your server's error log to find out the actual reason.

Have you completed the interview?
Reply
#5

Thank you. I looked in the server log and expected to find the 500 errors, but nothing there. However, I just tried to comment again and the browser error console shows this:

XMLHttpRequest cannot load http://[URL]/frontend/index.php?route=main/form/submit. Origin http://[URL] is not allowed by Access-Control-Allow-Origin.

I checked the file 'form.php' and changed its permissions to 755 because I had found before that sometimes PHP files on my server must be that or they won't execute. But it didn't help. So what exactly is "Access-Control-Allow-Origin"?

I also commented out the .htaccess file in the base URL of Commentics on the chance it might be the problem. Did not help.
Reply
#6

(03-Jan-2018, 09:38 AM)amwassil Wrote:  Thank you. I looked in the server log and expected to find the 500 errors, but nothing there. However, I just tried to comment again and the browser error console shows this:

XMLHttpRequest cannot load http://[URL]/frontend/index.php?route=main/form/submit. Origin http://[URL] is not allowed by Access-Control-Allow-Origin.

I checked the file 'form.php' and changed its permissions to 755 because I had found before that sometimes PHP files on my server must be that or they won't execute. But it didn't help. So what exactly is "Access-Control-Allow-Origin"?

I also commented out the .htaccess file in the base URL of Commentics on the chance it might be the problem. Did not help.


"Access-Control-Allow-Origin" is Apache .htaccess stuff. I'm running Commentics from a subdomain and accessing it from the primary domain. The .htaccess file causing the problem is in the subdomain.

Neither of these work:
Access-Control-Allow-Origin: http://[primary domain]
Access-Control-Allow-Origin: *

I would really like to keep Commentics in a subdomain, but is that going to prevent it working at all? Thanks.
Reply
#7

(03-Jan-2018, 09:52 AM)amwassil Wrote:  
(03-Jan-2018, 09:38 AM)amwassil Wrote:  Thank you. I looked in the server log and expected to find the 500 errors, but nothing there. However, I just tried to comment again and the browser error console shows this:

XMLHttpRequest cannot load http://[URL]/frontend/index.php?route=main/form/submit. Origin http://[URL] is not allowed by Access-Control-Allow-Origin.

I checked the file 'form.php' and changed its permissions to 755 because I had found before that sometimes PHP files on my server must be that or they won't execute. But it didn't help. So what exactly is "Access-Control-Allow-Origin"?

I also commented out the .htaccess file in the base URL of Commentics on the chance it might be the problem. Did not help.


"Access-Control-Allow-Origin" is Apache .htaccess stuff. I'm running Commentics from a subdomain and accessing it from the primary domain. The .htaccess file causing the problem is in the subdomain.

Neither of these work:
Access-Control-Allow-Origin: http://[primary domain]
Access-Control-Allow-Origin: *

I would really like to keep Commentics in a subdomain, but is that going to prevent it working at all? Thanks.
This is NOT an Apache .htaccess issue. I think I need to add "Access-Control-Allow-Origin: http://[primary domain]" to the header of frontend/index.php. Tried that, too, to no avail.
Reply
#8

I was correct. It was the subdomain causing the problem. By changing that to a simple directory and changing the site system settings, I can now post comments successfully.

I am going to attempt to figure out how to get Commentics to work out of a subdomain. That is my preference if it's possible.
Reply
#9

I haven't tested this but you might try opening /frontend/index.php

Replace this:
PHP Code:
<?php 
if (!headers_sent()) {
header('Content-Type: text/html; charset=utf-8');
}

With this:
PHP Code:
<?php 
if (!headers_sent()) {
header('Content-Type: text/html; charset=utf-8');
header('Access-Control-Allow-Origin: *');
}

If that works you could then lock it down by changing the * to your own domain.

Let me know how it goes.

Have you completed the interview?
Reply
#10

I tried this first:

if (!headers_sent()) {
header('Content-Type: text/html; charset=utf-8');
header('Access-Control-Allow-Origin: *');
}

Then this:

<?php
header('Access-Control-Allow-Origin: [http://[main url]');

Neither worked. However, removing the subdomain has fixed all problems and the comment function works without issues, so for now I'm going to leave it working as is. For testing/experimentation I will likely do another clean install in a subdomain and try to get it working from there. I'll report back if I do.

Thanks very much for you help.

Michael
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Ben
24-Aug-2023, 02:16 AM
Last Post by Steven
23-Aug-2023, 08:08 PM
Last Post by nsuomine
20-Jan-2023, 08:32 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)