0

I'm sending data with ajax to my asp classic page - with new FormData() and my alert shows [object FormData] so it should be right? But Im trying to display the variables "folderName" from my asp page in my success alert but it is not showing anything.

So how do I receive the formData on my asp page?

This is what I have now

var formData = new FormData($$(page.container).find('#pdffile')[0]);
formData.append("folderName", "manmade");
myApp.alert(formData); //this shows [object FormData]

$$.ajax({
method: 'POST',
url: 'dokument/dokument2.asp',
//processData: false,
//contentType: false,
enctype: 'multipart/form-data',
data: formData,
       success: function (data) {
           myApp.alert(data)//I get nothing in the alert?
        }

        });

        return false;
});

and in my asp page I just use request.form!?

<%
folderName = request.form("folderName")
%>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
    <%=folderName%>
</body>
</html>

I don't know why I can´t receive the variable on my asp page? Any input really appreciated, thanks.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Claes Gustavsson
  • 5,509
  • 11
  • 50
  • 86
  • If the purpose of dokument2.asp is to populate a js alert, is html (rather than plaintext or xml) the correct format for the output? – John Dec 29 '15 at 16:32
  • I don't see an evident problem with the code, have you verified you are in fact sending the data you can do that using firebug, developer tools in or fiddler ? – Rafael Dec 29 '15 at 19:31
  • John, if I send it with just - data:some variable, then I get it in the alert but not if I use formData? – Claes Gustavsson Dec 29 '15 at 19:53
  • Rafael, Im not sure, Im looking in the network inspector in safari and it says it has send 459 B, but Im not sure? Im not so sure what to look for? – Claes Gustavsson Dec 29 '15 at 19:55
  • Possible duplicate of [How to send FormData objects with Ajax-requests in jQuery?](http://stackoverflow.com/questions/6974684/how-to-send-formdata-objects-with-ajax-requests-in-jquery) – user692942 Dec 30 '15 at 01:10
  • check this: http://stackoverflow.com/a/3661121/1682881. You cannot use `Request.Form` when the enctype is `multipart/form-data` – Flakes Dec 30 '15 at 06:17

1 Answers1

0

try this for second asp file


<%
folderName = request.form("folderName")
%>
<%= folderName%>

line with

enctype: 'multipart/form-data' 

in first file have to be removed. You can not access multipart/form-data from asp without special libs...

DimaSUN
  • 921
  • 8
  • 13
  • DimaSun, no it is not working. No matter what I do I get noting in my alert on the asp page. Im trying to upload a .pdf file and save it on my server, but when I test to just get the folderName variable in the alert I get nothing? I just don´t know where I go wrong? – Claes Gustavsson Jan 04 '16 at 12:29
  • Thats true you need a component to upload i remember one was name freeaspupload idk is still there – Rafael Jan 06 '16 at 18:06
  • Rafael. Ok, I have a component called aspsmartupload, and if I post the form without ajax, then I can save the .pdf file, but if I do it with ajax it is not working, it is not finding the the form field with the file. Im using mySmartUpload.files.item(1).saveas("path/filename") when I post without ajax and then it saves it, but not with ajax? – Claes Gustavsson Jan 07 '16 at 08:37
  • Claes, did you ever figure this out? I am doing with non file upload but the ajax is sending back in a format that the request.form is not populated. I think it it content type related, but I cannot change that since it is a set script I cannot control. Any feedback would be appreciated!!! thank you :) – Dennis Dec 05 '20 at 15:10