[jQuery] Form with multipart/form-data not working

2007-06-11 Thread Neil Merton

Hi all,

I'm trying to use the following example with a form that contains
multipart/form-data in it but the ajax part won't work -
http://www.shawngo.com/gafyd/index.html

If I remove the enctype=multipart/form-data from the form tag it
works.

Here's the code...

script type=text/javascript src=/code/jquery.js/script
script type=text/javascript
$(document).ready(function()
{
$('#loading').hide();
$('#product_code').blur(function()
{
$('#loading').show();
$.post(checkproductcode.cfm,
{
product_code: $('#product_code').val()
},
function(response)
{
$('#result').fadeOut();
setTimeout(finishAjax('result', 
'+escape(response)+'), 400);
});
return false;
});
});
function finishAjax(id, response)
{
$('#loading').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
/script

form action=/checkproductcode.cfm method=post enctype=multipart/
form-data
input type=text name=product_code id=product_code
class=button size=50 /
span id=loadingimg src=ajax-loader.gif alt=Loading... //
span
span id=result/span
br /
input type=submit value=Send /
/form

Any ideas?

Thanks in advance for any replies



[jQuery] Re: Form with multipart/form-data not working

2007-06-11 Thread Neil Merton

Thanks for the reply guys.

Mike - I'll have a look at the application/x-www-form-urlencoded
option, see what it does.

Michael - that is a simplified form - the actual form does contain a
file upload field.

Regards,

Neil

On Jun 11, 5:19 pm, Michael Price [EMAIL PROTECTED] wrote:
 Looking at the sample form code provided, it doesn't look like it needs
 multipart/form-data anyway - isn't that only required when a file is
 being uploaded as part of the form submission?

 Regards,
 Michael Price





 Mike Alsup wrote:

  jQuery does not perform multipart/form-data encoding.  It uses
  JavaScript's encodeURIComponent function to encode data so the correct
  enctype is application/x-www-form-urlencoded.

  Mike

  On 6/11/07, Neil Merton [EMAIL PROTECTED] wrote:

  Hi all,

  I'm trying to use the following example with a form that contains
  multipart/form-data in it but the ajax part won't work -
 http://www.shawngo.com/gafyd/index.html

  If I remove the enctype=multipart/form-data from the form tag it
  works.

  Here's the code...

  script type=text/javascript src=/code/jquery.js/script
  script type=text/javascript
  $(document).ready(function()
  {
  $('#loading').hide();
  $('#product_code').blur(function()
  {
  $('#loading').show();
  $.post(checkproductcode.cfm,
  {
  product_code: $('#product_code').val()
  },
  function(response)
  {
  $('#result').fadeOut();
  setTimeout(finishAjax('result',
  '+escape(response)+'), 400);
  });
  return false;
  });
  });
  function finishAjax(id, response)
  {
  $('#loading').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
  }
  /script

  form action=/checkproductcode.cfm method=post enctype=multipart/
  form-data
  input type=text name=product_code id=product_code
  class=button size=50 /
  span id=loadingimg src=ajax-loader.gif alt=Loading...
  //
  span
  span id=result/span
  br /
  input type=submit value=Send /
  /form

  Any ideas?

  Thanks in advance for any replies

 --
 Regards, Michael Price - [EMAIL PROTECTED]
 ---
 Edward Robertson Ltd.  - 1 Bondgate, Darlington, DL3 7JA
 Direct: 01325 245077   -http://www.edwardrobertson.co.uk
 Office: 01325 489333   -http://www.internetwebsitedesign.co.uk
 ---
 Registered Address:
 1 Bondgate, Darlington, County Durham, DL3 7JA, UK
 Registration Number: 3931089 - Company registered in England
 ---
 This electronic message transmission contains information from
 Edward Robertson Limited that may be proprietary, confidential
 and/or privileged. The information is intended only for the use
 of the individual(s) or entity named above. If you are not the
 intended recipient, be aware that any disclosure, copying,
 distribution or use of the contents of this information is
 prohibited. If you have received this electronic transmission
 in error, please notify the sender immediately by replying to
 the address listed in the From: field.- Hide quoted text -

 - Show quoted text -