Avatar of ITsolutionWizard
ITsolutionWizard
Flag for United States of America asked on

Ajax call for data and upload

Below ajax code working but now I have to add file upload together.
Is it possible to submit form data such as text box and upload jpg in one ajax call?


<div class="row">
                <div class="col-fs-12">
                    <input type="file" />
                </div>
            </div>

$.ajax({
                                url: ApiName,
                                datatype: "text",
                                data:
                                {
                                    'blogid': blogID,
                                    'blogsubject': blogsubject,
                                    'blogbody': body.replace("'"," "),
                                    'createdby': '@System.Configuration.ConfigurationManager.AppSettings["MemberIDDefaultContentWriterName"]',
                                    'createdon': blogdate,
                                    'stage': blogStage,
                                    'actiontype': blogActionType,
                                    'blogurl': blogFileName,
                                    'memberid': '@System.Configuration.ConfigurationManager.AppSettings["MemberIDDefaultContentWriter"]',
                                    'blogtype': 'Event',
                                    'eventtype': eventType,
                                    'eventid': eventID,
                                    'eventIcon': eventIcon
                                },
                                type: "POST",
                                success: function (data) {
                                    var id = data.BlogID;
                                    alert("Update accordingly");
                                    //window.location.href = entireURL;
                                     },
                                error: function (error) {
                                    alert("Error " + error);
                                }
                            });

Open in new window

JavaScriptAJAX

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
ITsolutionWizard

ASKER
Any help
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ITsolutionWizard

ASKER
Do u have Mvc example like how to pick up the file and data using Mvc controller?
ITsolutionWizard

ASKER
any helps?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Julian Hansen

Do u have Mvc example like how to pick up the file and data using Mvc controller?
Unfortunately I don't.

I would recommend opening a separate question for that in the .Net topic area.