Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Cotroller giving the result and TempData["DCFormList"] showing count 3(key, value and success message) but in ajax call i am getting alert("fail") . I am working on jquery, mvc and C#.

What I have tried:

public ActionResult INTImportData()
       {
           if (Session["UserLogon"] != null)
           {
               BLINTForms objForm = new BLINTForms();
               objDCFormList = new DCFormList();
               int jobId = Session["Job_ID"] == null ? 0 : (int)Session["Job_ID"];
               ViewBag.jobId = jobId;
               objDCFormList.Form = objForm.GetINTFormTempDataByJobId(jobId);
               TempData["DCFormList"] = objDCFormList.Form;

               return View(objDCFormList.Form);
           }
           else
               return Redirect("~/Account/Login");

       }

 function GetINTFormTempData(JobId) {
       var result = null;
       $.ajax({
           type: "GET",
           url: '/ImportForms/GetINTFormTempDataByJobId',
           data: { jobId: JobId },
           async: false,
           traditional: false,
           success: function (data)
               {
                   result = data;
                   LoadINTData(result);
                   if (result.length > 0)
                       $(".upload").show();
                   else
                       $(".upload").hide();
               },
           error: function (data)
           {
               alert("fail");
               Success = false;
           }
Posted
Updated 8-Dec-19 23:52pm
Comments
F-ES Sitecore 22-Feb-19 6:57am    
Use the network tab of the browser tools to inspect the ajax call to see if an error message is in the result. Also step through the controller in the debugger to ensure it is doing what you think it is doing.
GKP1992 22-Feb-19 7:00am    
And what does the data in the error function say? Try to debug a little. Probably it has "404 not found" error.

1 solution

check GetINTFormTempDataByJobId for the following

1.It must be public.
2.Return Type String/ActionResult/JsonResult
3.Whether it is get/post method.
4.Parameter Name "jobId" must be same as in your call.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900