Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Intro Black Friday Offer for a lifetime*

Code Validation AJAX Error

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
5 years 5 months ago - 5 years 5 months ago #312538 by sysopcrew
Code Validation AJAX Error was created by sysopcrew
I'm having trouble with AJAX Code Validation on a normal Checkbox (Multiple) field. I have 5 options, and I want users to be able to possibly select multiple options EXCEPT a specific combo of two (example: options a, b, c, d, f. They can select any except b and c together.) However, I can't get Code Validation with AJAX to work. All profile edits are done via profile view through AJAX fields. Edit Profile only displays the basic username, email, and name. For the sake of testing, I have set the PHP for Code Validation to return false; to force an error. However, when editing the AJAX field, this is thrown in the browser Dev Console as I change check box selections in AJAX editing:
Code:
jquery.cbvalidate.min.js?v=97c6c7d74dea204d:1 Uncaught TypeError: Cannot read property 'valid' of null at Object.<anonymous> (jquery.cbvalidate.min.js?v=97c6c7d74dea204d:1) at u (jquery-2.2.4.min.js?v=97c6c7d74dea204d:1) at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js?v=97c6c7d74dea204d:1) at u (jquery-2.2.4.min.js?v=97c6c7d74dea204d:1) at XMLHttpRequest.<anonymous> (jquery-2.2.4.min.js?v=97c6c7d74dea204d:1)

Community Builder 2.4.2
CB Code Field 2.0.0+build.2019.03.21.15.21.42.54835dad0
PHP Version 7.1.29
Joomla! Version Joomla! 3.9.5 Stable [ Amani ] 9-April-2019 15:00 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

--
David Riviera
Last edit: 5 years 5 months ago by sysopcrew.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48554
  • Thanks: 8292
  • Karma: 1445
5 years 5 months ago #312549 by krileon
Replied by krileon on topic Code Validation AJAX Error
Enable debug mode and maximum error reporting in Joomla global configuration then retry. This should allow the error to provide an actual line number that can be investigated to see where in the JS it's failing. Please note your PHP should be returning a true or false only.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
5 years 5 months ago #312552 by sysopcrew
Replied by sysopcrew on topic Code Validation AJAX Error
For the sake of this test, I have one line of PHP:
Code:
return false;
When I clicked on a checkbox in Profile view, AJAX editing mode:
Code:
jquery.migrate.js?v=97c6c7d74dea204d:45 JQMIGRATE: jQuery.parseJSON requires a valid JSON string migrateWarn @ jquery.migrate.js?v=97c6c7d74dea204d:45 jQuery.parseJSON @ jquery.migrate.js?v=97c6c7d74dea204d:304 text json @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1082 ajaxConvert @ jquery-2.2.4.js?v=97c6c7d74dea204d:8249 done @ jquery-2.2.4.js?v=97c6c7d74dea204d:8710 (anonymous) @ jquery-2.2.4.js?v=97c6c7d74dea204d:9126 load (async) send @ jquery-2.2.4.js?v=97c6c7d74dea204d:9145 ajax @ jquery-2.2.4.js?v=97c6c7d74dea204d:8659 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1072 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1016 (anonymous) @ VM246:4 check @ jquery.validate.js?v=97c6c7d74dea204d:777 element @ jquery.validate.js?v=97c6c7d74dea204d:492 onchange @ jquery.cbvalidate.js?v=97c6c7d74dea204d:335 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:351 dispatch @ jquery-2.2.4.js?v=97c6c7d74dea204d:4740 elemData.handle @ jquery-2.2.4.js?v=97c6c7d74dea204d:4552 jquery.migrate.js?v=97c6c7d74dea204d:47 console.trace migrateWarn @ jquery.migrate.js?v=97c6c7d74dea204d:47 jQuery.parseJSON @ jquery.migrate.js?v=97c6c7d74dea204d:304 text json @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1082 ajaxConvert @ jquery-2.2.4.js?v=97c6c7d74dea204d:8249 done @ jquery-2.2.4.js?v=97c6c7d74dea204d:8710 (anonymous) @ jquery-2.2.4.js?v=97c6c7d74dea204d:9126 load (async) send @ jquery-2.2.4.js?v=97c6c7d74dea204d:9145 ajax @ jquery-2.2.4.js?v=97c6c7d74dea204d:8659 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1072 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:1016 (anonymous) @ VM246:4 check @ jquery.validate.js?v=97c6c7d74dea204d:777 element @ jquery.validate.js?v=97c6c7d74dea204d:492 onchange @ jquery.cbvalidate.js?v=97c6c7d74dea204d:335 (anonymous) @ jquery.cbvalidate.js?v=97c6c7d74dea204d:351 dispatch @ jquery-2.2.4.js?v=97c6c7d74dea204d:4740 elemData.handle @ jquery-2.2.4.js?v=97c6c7d74dea204d:4552
And
Code:
Uncaught TypeError: Cannot read property 'valid' of null at Object.<anonymous> (jquery.cbvalidate.js?v=97c6c7d74dea204d:1102) at fire (jquery-2.2.4.js?v=97c6c7d74dea204d:3190) at Object.fireWith [as resolveWith] (jquery-2.2.4.js?v=97c6c7d74dea204d:3320) at done (jquery-2.2.4.js?v=97c6c7d74dea204d:8760) at XMLHttpRequest.<anonymous> (jquery-2.2.4.js?v=97c6c7d74dea204d:9126)

--
David Riviera

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48554
  • Thanks: 8292
  • Karma: 1445
5 years 5 months ago #312575 by krileon
Replied by krileon on topic Code Validation AJAX Error
Looks like something is breaking the validation endpoint. Seams to be working fine in my tests. Please PM backend super administrator login credentials and note what field is failing validation to reproduce your issue and will take a look. It's possible something is doing an echo and breaking the JSON response of the validation endpoint.

That error could only happen if the following check failed.

Code:
if ( ( cbGetParam( $_GET, 'function', null ) == 'codevalidate' ) && $this->canValidate( $field, $user, $reason ) ) {

So either the function value in the URL of the validation endpoint is being altered or the field isn't properly accessible for ajax validation, but if it's not accessible for ajax validation it shouldn't have been possible for it to attempt validation to begin with.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum