I used to run into Javascript errors when dealing with folders as well. If all you're doing is some basic SPServices stuff, Marc's suggestion to set the debug to false is plenty sufficient. I've got some forms that are doind quite a bit of processing on load and on save. I took it a step further to detect if I'm dealing with a folder or not. If I am dealing with a folder, I generally don't want all that processing to run. There's two methods to employ depending on whether you're working with the NewForm.aspx or the EditForm.aspx.
The NewForm.aspx provides an argument in the query string that makes it really easy to know you're dealing with a folder and to subsequently abort...
var qs; $(document).ready(function() { qs = $().SPServices.SPGetQueryString();//If this is a folder, don't do anythingif(qs.Type == 1) return;//If we get here, it's not a folder...Do a lot of other stuff//... });function PreSaveAction(){//If this is a folder, don't do anythingif(qs.Type == 1) returntrue;//If we get here, it's not a folder...Do a lot of other stufftry{//...returntrue; }catch(err) { alert(err.message);returnfalse; } }
The EditForm.aspx doesn't provide this argument but it's easy enough to look up...
var booFolder = new Boolean(false);var qs; $(document).ready(function() { qs = $().SPServices.SPGetQueryString();//If this is a folder, don't do anything $().SPServices({ operation: "GetListItems", async: false, listName: "List Name", CAMLViewFields: "<ViewFields><FieldRef Name='ContentType' /></ViewFields>", CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Integer'>" + qs.ID + "</Value></Eq></Where></Query>", CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", completefunc: function(xData, Status) {if($(xData.responseXML).SPFilterNode("z:row").attr("ows_ContentType") == "Folder") booFolder = true; } });if(booFolder == true) return;//If we get here, it's not a folder...Do a lot of other stuff//... });function PreSaveAction(){//If this is a folder, don't do anythingif(booFolder == true) returntrue;//If we get here, it's not a folder...Do a lot of other stufftry{//...returntrue; }catch(err) { alert(err.message);returnfalse; } }