FormData for sending data in HttpRequest

447 views
Skip to first unread message

Jonathan Zernik

unread,
Dec 2, 2012, 12:14:48 PM12/2/12
to mi...@dartlang.org
I am trying to use the FormData class to send data to my server with HttpRequest.send(). I need to do a POST request with multiple fields. It should work the same as this Javascript code:

 //Upload File
 var uploadFile = function(file, tag, callback){
     var xhr = new XMLHttpRequest();
     xhr.open('POST', "upload/", true);
xhr.onreadystatechange=function() { if (xhr.readyState==4 && xhr.status==200) { callback(); } } var formData = new FormData(); formData.append('file', file); formData.append('tag', tag); var csrftoken = $.cookie('csrftoken'); xhr.setRequestHeader("X-CSRFToken", csrftoken); xhr.send(formData); };

But FormData doesn't seem to work the same way in Dart. Could someone explain how to do this in Dart, if it is possible?

Shailen Tuli

unread,
Dec 4, 2012, 11:22:43 PM12/4/12
to mi...@dartlang.org

Seth Ladd

unread,
Dec 8, 2012, 1:18:04 AM12/8/12
to General Dart Discussion
And here's the bug: http://code.google.com/p/dart/issues/detail?id=7152  And great news, it's fixed!  Thanks for the feedback! BTW Stack Overflow was a great channel for posting these kind of questions or issues.


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 

Reply all
Reply to author
Forward
0 new messages