I want List of data and multiple images are added in view.then this all data are passed to the Action through Ajax.how to solve this problem help me....
- <input type="file" id="file1" name="file" multiple />
- for (var i = 0; i < arr.length; i++) {
- resultQuiz.push({
- Id: Id,
- Message: 'Rating Star',
- selectedAnswerOptionID: arr[i].starId,
- value: arr[i].value,
- });
- }
- var fileUpload = $("#file1").get(0);
- var files = fileUpload.files;
- var fileData = new FormData();
- var lenimg = [];
- for (var i = 0; i < files.length; i++) {
- lenimg.push({
- names:files[i].name,
- })
- //fileData.append(files[i].name, files[i]);
- }
- debugger;
- for (var j = 0; j < lenimg.length; j++)
- {
- resultQuiz.push({
- Id: Id,
- Message: 'Images',
- selectedAnswerOptionID: lenimg[j].names,
- value: "",
- });
- }
- $.ajax({
- type: 'POST',
- url: '@Url.Action("QuizTest", "Quizz")',
- //data: fileData ,
- data: { resultQuiz},
- contentType: 'application/json; charset=utf-8',
- dataType: 'json',
- //processData: false,
- //cache: false,
- success: function (response) {
- if (response != null) {
- alert("Survey Save uccessfully.");
- }
- else {
- alert("Survey Save uccessfully.");
- }
- },
- error: function (response) {
- }
- });
- console.log(resultQuiz);
- });
- });
- public ActionResult QuizTest(FormCollection form,List
resultQuiz) - {
- return view();
- }
Kalyani ShevalePosted Sep 19, 2018, 7:43 AM
Sanwar RanwaPosted Sep 19, 2018, 7:22 AM