Hello everyone...!!
Did I make mistake?
Everytime I do request.getParameter("dataString"); ----> inside my JSP processor
it always returned me NULL.
Actually I do posting the variable dataString with a value;
Take a look at this my jquery;
(correct me if I'm wrong);
- var content;
- var dataString="ha";
- $( function() {
- $.validator.addMethod("username", function(value, element) {
- return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
- }, "UserID: only letters, numbers, or underscore.");
- $('#userAccountForm').validate();
- $('input').focus( function() {
- content = $(this).val();
- if(content=='- none -') {
- $(this).val("");
- }
- } );
-
- $('input').blur( function() {
- content = $(this).val();
- if(content=='') {
- $(this).val("- none -");
- }
- } );
- var options = {
- target: "#result",
- url: "user-form-function",
- beforeSubmit: validate,
- data: dataString,
- success: getResponse
- };
- $('#userAccountForm').ajaxForm(options);
- } );
- function validate(formData, jqForm, options){
- var emptyThing = "- none -";
- // ensure all fields are not empty
- // we use word - none - as empty field
- var usName = $('#username').val();
- var email = $('#email').val();
- var contc = $('#mobilephone').val();
- // var photo = $('#avatar').val();
- var usId = $('#userid').val();
- var pass = $('#password').val();
- var editClient = $('input:radio[name=editClient]:checked').val();
- var addClient = $('input:radio[name=addClient]:checked').val();
- var delClient = $('input:radio[name=deleteClient]:checked').val();
- var adminPriv = $('input:radio[name=adminPriv]:checked').val();
-
- if(adminPriv==undefined){
- alert("it is not admin okay?");
- adminPriv = "staff";
- } else {
- adminPriv = "administrator";
- }
- if(usName==emptyThing){
- usName = "none";
- }
- if(contc==emptyThing){
- contc = "0";
- }
- if(pass==emptyThing){
- pass = "default";
- }
-
- dataString = "username="+usName+"&"+"contact="+contc+"&"+"email="+email+"&"+"userid="+usId+"&"+"password="+pass+"&"+"editclient="+editClient+"&"+"addclient="+addClient+"&"+"deleteclient="+delClient+"&"+"adminprivillege="+adminPriv;
- // animate
- $('#userAccountForm').fadeOut(1000, function(){
- $('#loadingBar').show();
- $('#loadingBar').fadeIn("slow");
- } );
- return true;
- }
- function getResponse(html){
- $('#loadingBar').fadeOut(500);
- $('#result').html(html).show();
- alert("in getting response");
- }