I have created a few Safecracker forms and have been using the jqueryForm plugin with great success. I’ve noticed that when I use JSON to output the response, before I get the list of errors there’s a string which reads ‘undefined’ which displays before the Field Errors. If I go into Firebug or the Chrome Developer Toolbar, go through the console, and comb through the whole response, I can’t see any ‘undefined’ anything in the Field Errors. There’s a sea of other data, and searching for ‘undefined’ via those tools doesn’t pull anything up.
I’ve seen the same thing in all the EE sites I use Safecracker in. Has anyone else seen this? Is it just an ajaxForm thing?
Thanks in advance.
Hi dehuszar,
Other than the “Undefined” error, is SafeCracker saving your data and otherwise functioning correctly? The 2 plug-ins you mention, are those jQuery or ExpressionEngine add-ons?
I’m going to move this into Development and Programming for the time being. That way the Development Community can chime in with their experiences.
Cheers,
Hi Dan,
Safecracker is an EE Addon that is now bundled with ExpressionEngine. jqueryForm is a jquery plugin. After a little more digging I’ve determined that the DOM Object ‘window’ contains an entry titled ‘Lst’ which is undefined.
It could just be in the jquery, but by default, Safecracker includes it’s own instance of jquery and a form header with common jquery form tools. I have them all disabled, but I’m wondering if the form, on submit, is trying to reference a function that it expects to be in that header, but since I’ve turned all that stuff off and am using my own copies of jquery libraries whatever it might be loading is not ‘defined’.
I’m not the greatest at debugging these kinds of things, so any input would be appreciated.
Has anyone been able to figure this out? I’m having the same issue. Every time a legitimate error is reported, it starts with “undefined” in the array. Looking at the json data in firebug, I’m only seeing the “real” error and that’s it.
I’m using this code to get the error info:
window.console.log〈data〉;
var errors_html;
var i=1;
for(i in data.field_errors) {
errors_html += '
'+data.field_errors[i];
}
$( "#dialogFailure" ).html("Uh-oh. Your submission failed with the following errors:<br>"+errors_html);maybe there is a better way to get the field_errors?
duh - I just figured it out. Since the variable called errors_html is using a += operator, it needed to be defined before that. Here’s a fix to the code in case someone else needs it:
window.console.log〈data〉;
var errors_html=''; <<<<<<<<<<<<<<<<<<< add ='' right here after errors_html
var i=1;
for(i in data.field_errors) {
errors_html += '
'+data.field_errors[i];
}
$( "#dialogFailure" ).html("Uh-oh. Your submission failed with the following errors:<br>"+errors_html);Apologies if this is a silly question, but could not setting errors_html to a null value possibly produce duplicate entries once the errors were resolved?
I have another bug I’m trying to quash that involves jqueryForm occasionally producing multiple identical instances of a submitted entry, and I’m not too experienced with this kind of debugging.
I can’t quite figure out why some entries get these duplicates and why the range (anywhere from 2 to 10 when it happens), but it occurred to me that if there was any correlation at all between these two issues, there could be some correlation between the number of errors that a given form could produce and the number of duplicate entries produced once the form is filled out completely.
Either way, thanks for the update! My code shared the same error.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.