jQuery .ajax() settings - weird issue with serializeArray()

Hello, all,

I have been working on a few forms that submit form data via $.ajax();, and recently had a weird issue that I’m hoping someone can explain to me.

I have three forms that have been submitting data flawlessly. I have another form that was giving me a 404 (not found) error.

On the form that was giving me an error (it’s now fixed), I changed this:

$('#submitBtn').on('click',function(e){
      frm = $('#estimateForm');
      frm = frm.serializeArray();
      postURL = 'http://www.domain.com/components/ERC.cfc?method=getCostEstimate';
      $.ajax({
          type: 'post',
          url: postURL,
          data: frm  
}).done(function(data){alert(data)});

… to this:

$('#submitBtn').on('click',function(e){
      postData = $('#estimateForm').serializeArray();
      postURL = 'http://www.domain.com/components/ERC.cfc?method=getCostEstimate';
      $.ajax({
          type: 'post',
          url: postURL,
          data: postData  
}).done(function(data){alert(data)});

The first was giving the 404 error; the second works just fine. Any ideas why?

V/r,

:slight_smile:

Apart from the difference in how the serializeArray result is assigned, there doesn’t seem to be much else that could cause the problem.

frm = $('#estimateForm');
frm = frm.serializeArray();

@AurelioDeRosa as our resident jQuery expert, is there any light that can be shone on this?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.