Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Another odd serializeArray() issue

$
0
0

Hello, all,

 

I'm working on a form that uses AJaX (jQuery) to submit the form data, after the fields have been serialized.

 

I've done this several times, and never had a problem.. until this.  I've compared this code to the code that is working elsewhere, and I'm just not seeing any differences that could cause my issue.

 

Here is some pseudo-code:

 

<form name="peopleSave" id="peopleSave" method="post">    <input type="text" name="firstName" id="firstName" value="" />  First Name    <br /><input type="text" name="lastName" id="lastName" value="" />  Last Name    <br /><input type="button" name="submitBtn" id="submitBtn" value="Submit" class="sbmt" /></form>

Here is actual code:

 

<script type="text/javascript" src="/scripts/jquery/jquery.min.js"></script><script type="text/javascript" src="/scripts/jquery/jquery-ui.js"></script><script type="text/javascript">    function validateData(formObjId){        var formObj = document.forms[formObjId],        postURL = "/components/recs.cfc?method=updMuster",        postData,        contentType = "application/json";        postData = $('#' + formObjId).serializeArray();        $.ajax({            type: "post",            url: postURL,            data: postData,            contentType: contentType            }).done(function(data){                switch(data.length){                    case 0:                        $('#content div').html('Update Failed');                    break;                    default:                        $('#content div').html(data);                    break;                    }                });        }    $(document).ready(function(){        $('.sbmt').on('click',function(e){            validateData($(this).parent('form').attr('id'));// use ID of form as argument - it works.            });        });</script>

 

Now, in the component (set for output just for debugging), all I'm doing is "cfdump var='#form#'" which returns an empty struct.  Nothing.  Form exists with a structcount of 0 (zero).

 

I can see in FireBug that the data is being posted.  The form _is_ sending the data - but the component isn't seeing any data, just an empty form.

 

This is working on three other forms on another project.  Why is this _not_ working, here?

 

V/r,

 

^_^


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>