Javascript javadoc - JSDoc
I was looking if there was any standards for writing Javascript API documentation and if there is a tool to parse and generate the document.
I found one which does this http://jsdoc.sourceforge.net/, seems like it solves the purpose I am looking for, have to try it out.
jQuery Form serialize method - does not post disabled fields
http://api.jquery.com/serialize/
Today I had a problem where I had some disabled fields which were not getting serialized, I got two solutions for this
*After serialize call, have code to get disabled fields name, value and append to the query string
*Or Instead of using disabled attribute , use readonly attribute ( http://www.htmlcodetutorial.com/forms/_INPUT_DISABLED.html
Validate/Revalidate a single field using jQuery validator
If you have a requirement to just do a single field validation, instead of calling the form validate method which will validate all the fields, then you have to use valid() method on the element
For example if your form has field
to validate only username field, use code
jQuery(‘#username’).valid() But of course you have to link the jQuery validator plugin with your form before you call this method
Related Stack overflow post link here - http://stackoverflow.com/questions/1378472/jquery-validate-can-i-re-validate-a-group-of-fields-after-changing-one
jQuery JSONP (JSON with padding) - success method not called
Possible reasons for JSONP success method not getting called*In jQuery.getJSON method check if you are adding the
callback=? param to your URL
*Check if your server code serving JSONP request is returning proper JSONP response,
For example sample server JSONP java code and response taken from IBM Developerworks article given below, Java code
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String jsonData = getDataAsJson(req.getParameter("symbol"));
String output = req.getParameter("callback") + "(" + jsonData + ");";
resp.setContentType("text/javascript");
PrintWriter out = resp.getWriter();
out.println(output);
}
JSONP Response Format
jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"});
To get a good understanding of JSONP you can read this IBM Developerworks article http://www.ibm.com/developerworks/library/wa-aj-jsonp1/
jQuery Validator - Error: $.validator.methods[method] is undefined
Error: $.validator.methods[method] is undefined
I was getting this error when using jQuery validator, found the reason for this error was because I didn’t define the custom validator methods which I had assigned in the validation rules. More about jQuery custom validation method here - http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage