Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
i use ajax post in separate js file as

JavaScript
$.ajax({
   type: "POST",
   contentType: "application/json; charset=utf-8",
   //url: "hotels.aspx/BindDatatable",
   url: '@Url.Action("hotels.aspx","BindDatatable")',
   /*data: "{}",*/
   data: "{'ToValue':'"+totval+"',"+"'checkin':'"+chkin+"',checkout:'"+ckhout+"'}",
   /*data:{ToValue:totval,checkin:chkin,checkout:ckhout},*/
   dataType: "json",
   success: function(data) {
      var theHtml = data.d;
      //  alert(data.d);
      window.location.href = data.d;
   },
   error: function(xhr, textStatus, errorThrown) {
      //alert("Error is " + result.value);
      alert("FAIL: " + xhr + " " + textStatus + " " + errorThrown);
   }
});


but get error as

internal server error

what is error.
i pass parameters in WebMEthod from here , which are in data{} in ajax post

and in asp.net hotels.aspx page , i use WebMethod

pls advice
Posted
Updated 26-Dec-13 21:53pm
v3

the error is in hotels.aspx.cs page. Debug the page to get the error.
 
Share this answer
 
Comments
maulikshah1990 27-Dec-13 3:04am    
i can now call web method
only changed

//url: "hotels.aspx/BindDatatable", // uncomment
url: '@Url.Action("hotels.aspx","BindDatatable")', //comment


.
-----------------

other issue is i want request.form value <input form values> in web method.
i use
int roomcnt = Convert.ToInt32(HttpContext.Current.Request.Form["selectroomname"]);
but get roomcnt =0
but selectroomname can have value 1 or 2 or 3

and
string setrname = HttpContext.Current.Request.Form["selectroomname"];
is null

what is issue
or how to get request.form values
comment the line
contentType: "application/json; charset=utf-8",

remove Forms
int roomcnt = Convert.ToInt32(HttpContext.Current.Request["selectroomname"]);
 
Share this answer
 
v2
Comments
maulikshah1990 27-Dec-13 3:12am    
your above suggestion did not work..pls advice

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