Don't like ads? PRO users don't see any ads ;-)
Guest

ajax

By: a guest on Jun 15th, 2012  |  syntax: JavaScript  |  size: 2.15 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. I tried to post multipart/form-data via:
  2. var request = $.ajax({
  3. url: form.attr('action'),
  4. contentType: 'multipart/form-data',
  5. data: form.serialize(),
  6. dataType    :   'json',
  7. type: (form.attr('method')),
  8. dataType: 'script'
  9. });
  10.  
  11. The content isn't send how it should :(
  12. expected header:
  13. Host: localhost
  14. User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0
  15. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  16. Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
  17. Accept-Encoding: gzip, deflate
  18. Connection: keep-alive
  19. Cookie: CAKEPHP=694lv1faqv8n65llmnbaamq2b7
  20. Content-Type: multipart/form-data; boundary=---------------------------40164743307933957103707336
  21. Content-Length: 274796
  22. -----------------------------40164743307933957103707336
  23. Content-Disposition: form-data; name="_method"
  24.  
  25. POST
  26. -----------------------------40164743307933957103707336
  27. Content-Disposition: form-data; name="data[Image][album_id]"
  28.  
  29. 1
  30. -----------------------------40164743307933957103707336
  31. Content-Disposition: form-data; name="data[Image][filename]"; filename="Bildschirmfoto vom 2012-06-11 06:24:37.png"
  32. Content-Type: image/png
  33.  
  34. ‰PNG
  35. 
  36.  
  37. real header:
  38. Host: localhost
  39. User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0
  40. Accept: text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01
  41. Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
  42. Accept-Encoding: gzip, deflate
  43. Connection: keep-alive
  44. Content-Type: multipart/form-data; charset=UTF-8
  45. X-Requested-With: XMLHttpRequest
  46. Content-Length: 110
  47. Cookie: CAKEPHP=694lv1faqv8n65llmnbaamq2b7
  48. Pragma: no-cache
  49. Cache-Control: no-cache
  50. _method=POST&data%5BImage%5D%5Balbum_id%5D=1&data%5BImage%5D%5Btitle%5D=sdad&data%5BImage%5D%5Bdescription%5D=
  51. HTTP/1.1 200 OK
  52. Date: Fri, 15 Jun 2012 21:04:34 GMT
  53. Server: Apache/2.2.22 (Ubuntu)
  54. X-Powered-By: PHP/5.3.10-1ubuntu3.1
  55. Vary: Accept-Encoding
  56. Content-Encoding: gzip
  57. Content-Length: 1442
  58. Keep-Alive: timeout=5, max=100
  59. Connection: Keep-Alive
  60. Content-Type: text/html; charset=UTF-8
  61. ----------------------------------------------------------