On the page Puzzle.aspx ego the following button:
<figure><asp:ImageButton id="puzzle1" runat="server" ImageUrl="~/images/puzzle1.jpg" class="img-rounded img-responsive image" OnClientClick="showModel('uno'); return false" /></figure>
That invokes the function showModel
passing it as a parameter String "one".
Function statement:
<script type="text/javascript" >
function showModel(variable) {
$.ajax({
type: "POST",
url: "Puzzle.aspx/addSession",
data: "{'hotelcode':'" + variable + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("ok");
$('.modal').modal();
},
error: function (err) {
alert("error");
}
});
return false;
}
</script>
In the case of success, it should show a modal, in the case of failure, it would show an alert with the message "error".
Code c # of the page Puzzle.aspx :
[WebMethod(EnableSession = true)]
public static void addSession(String hotelcode)
{
HttpContext.Current.Session["tipoPuzzle"] = hotelcode;
}
It always shows me the alert with error, it never goes by the success to show the modal window.
Can anyone help me with this problem please?