1

How do you use a $.post().serialize() to participate with a form that has a enctype="multipart/form-data" ?

Was reading the comment to the 3rd answerer here: Making an HTTP POST call with multipart/form-data using jQuery?

What is that referring to? I just need to submit it, i'm not trying to read the file client-side, but the server script doesn't seem to be reading the data properly.

Thanks.

3 Answers 3

1

You could some some plugin: http://www.phpletter.com/Our-Projects/AjaxFileUpload/

Sign up to request clarification or add additional context in comments.

Comments

0
$("#frmMember").submit(function(e){
e.preventDefault();
                        var formData = new FormData($(this)[0]);
                        $.ajax({
                            url: 'member/api/add',
                            type: 'POST',
                            dataType: 'json',
                            async: false,
                            cache: false,
                            contentType: false,
                            processData: false,
                            data: formData,
                            success: function(data){
                                if(data.status=="OK")
                                {
                                    alert(data.message);
                                    memberFormWindow.close();
                                } else {
                                    alert(data.message);
                                }
                            }
                        });
                    });

This work! try!

Comments

-3

You can't upload files via ajax.

You can try to fake the ajax-like upload using iframes, other methods, like java and flash uploaders.

2 Comments

If you are not uploading files, then why do you need that enctype? If you are trying to upload a file, then it is not possible.
Completely incorrect, check out this article, it solved the issue for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.