Jump to content
iwato

Failed AJAX Call -- No PHP Error Tracks

Recommended Posts

It appears not to like the data that it is receiving.  Do you agree.  If yes, do you have any ideas.  If not, I have no idea.

Roddy

Share this post


Link to post
Share on other sites

Because you're parsing the JSON data from the server,  if JSON.parse is failing it means that the PHP file may be incorrectly outputting the JSON.

This may come about as a PHP error(ending execution before output) or maybe its just malformed.

Check your Network tab of your webconsole, and see if you can find the call to the Captcha file. You'll be able to see what the server responded with.

Share this post


Link to post
Share on other sites

Before I do anything more I have a question.  Is it not likely that PHP had upgraded its json_encode() function, and that the JSON.parse function is no longer necessary as PHP has already performed the same action?

Roddy

Share this post


Link to post
Share on other sites

Regardless of what PHP does, all the JavaScript receives is a string(in this case) so processing still happens. But...

I just had a thought. the jQuery ajax success method takes an "intelligent guess" on what data is being received and parses accordingly. (I just looked it up because I wasn't sure)

It could be that you're attempting to JSON.parse a JSON object....

Try taking it out and seeing what happens.

Or you can console.log it and see if its an object or a string to be parsed.

 

Share this post


Link to post
Share on other sites

Before I try that I would like to bring your attention to a very important point:  your prior instruction was quite good.  It alerted me to the fact that I had failed to remove a var_dump of what was being received by the reset_captcha.php file. Your not gonna like what follows though.  The reset_captcha.php file is once again reporting a 500 error.  I am absolutely amazed, but somehow feel that we are coming closer.  Please do not leave.

Roddy

 

Share this post


Link to post
Share on other sites
15 minutes ago, iwato said:

Before I try that I would like to bring your attention to a very important point:  your prior instruction was quite good.  It alerted me to the fact that I had failed to remove a var_dump of what was being received by the reset_captcha.php file. Your not gonna like what follows though.  The reset_captcha.php file is once again reporting a 500 error.  I am absolutely amazed, but somehow feel that we are coming closer.  Please do not leave.

Roddy

 

I can stick around for a while Roddy. Just grabbed lunch(Oh New Zealand time) so I'm quite clear for the next few hours.

  • Thanks 1

Share this post


Link to post
Share on other sites

OK.  I have found a real error.  Not only does it appear that I have not been keeping current, (If only you knew how difficult it hsa been.) but also the originator of the software that I am using.  I now have what I believe to be a bug.  Any ideas on how to fix it.

[05-Jan-2020 23:08:20 UTC] PHP Parse error:  syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /home/.../vendor/villfa/invert-color/src/Color.php on line 16

Here is the relevant link:  https://github.com/villfa/php-invert-color

In my code the error occurs here:

$color_pair = select_color_pair(true);
$ictext_color = $color_pair['text_color'];
Edited by iwato
Add my code and point out where the failure in the developers code becomes an error for me.

Share this post


Link to post
Share on other sites

Your server has to be running PHP 7.1 or higher to allow the public modifier on the const keyword.

Share this post


Link to post
Share on other sites

The furtive fox has returned.   Please note, Ingolme, the following from cPanel.

dev...rs.grammarcaptive.com                  PHP 7.2 (ea-php72)
Edited by iwato

Share this post


Link to post
Share on other sites

The error message you are getting indicates that the PHP version is most likely the issue. Make an empty PHP file and run the phpversion() function to verify that the version is what you need it to be.

  • Thanks 1

Share this post


Link to post
Share on other sites

The phpversion() function is not available to me, but the phpinfo() function is.  It yielded PHP Version 7.0.33 when I ran it.  I am beginning to feel the need to dump cPanel.  This is the second major problem that I have had with it, and CENTOS WHM appears to handle everything that cPanel does and more without all of the frustration.  CPanel was useful while I was on a shared server, but I now have my own.

I will return later with the outcome.

Roddy

Share this post


Link to post
Share on other sites

Thank you, Funci, for your very hard effort.  Together we nailed the source of the problem.

And, thank you, Ingolme, for providing the solution.

Once again, I wish Ingolme, Funci, Dsonesuk, and everyone else at W3Schools a very Happy New Year!

Roddy

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...