I have a web page that calls back to my web service. Occasionally, a 404 may occur. I am trying to detect that using the structure:
$.ajax({
url: "/myService/myAction",
contentType: "application/json",
success: action_Succeeded,
error: action_Failed
});
function action_Succeeded() {
// Do stuff
}
var v = 0;
function action_Failed(p1, p2, p3) {
if (p1.status != 200) {
if (ServerSideObject.COUNT == v) {
// Do Stuff
}
}
}
I have a class on the server with a publicly visible int called COUNT; How do I plug that value in where “ServerSideObject.Property” exists? I thought I could use @ServerSideObject.Property but that doesn’t seem to work. How do I plug this value in? For reference, ServerSideObject looks like the following:
public class ServerSideObject
{
public const int COUNT = 3;
}
Thank you for your help!
Using razor in view within javascript block does work, but editor shows some errors caused by javascript editor not supporting razor. Ignore them and try what it does in browser.