views:

47

answers:

2

I have build a webapplication using ASP.NET MVC and JQuery. On my local machine this works fine,but when moving it to a Windows server 2003 the JQuery method post stops working. I'm also using the load method and this works fine.

function methodOne(id) {
    alert("debug1: <%= Url.Action( "MethodOne", "controller" ) + "/" %>" + id);
    $.post <%= Url.Action( "MethodOne", "controller" ) + "/" %>" + id, function(data) {
        alert("debug2");
        ...
        } else {
            alert("Debugg: Add presentation to user failed");
        }
     });
}

The debug2 is never outputed.

$('#panel').load("<%= Url.Action( "Method", "Controller" ) %>");

Works fine.

+1  A: 

You have an error in your post function: opening parenthesis and quotes are missing. Also try passing an empty data as second argument to see if this works:

var url = '<%= Url.Action( "MethodOne", "controller" ) %>/' + id;
$.post(url, { }, function(data) {
    alert('success');
});
Darin Dimitrov
karl
@karl, do you get some error? Can you try using FireBug and see if the request is sent and if the server responds?
Darin Dimitrov
Yeah you are right. I got a 404 error. The url is /mycustompage.htm?aspxerrorpath=/Controller/MethodOne/5. I don't know why the /mycustompage.htm?aspxerrorpath= is added but i'ts a start
karl
hmm I also notice with firebug that it first makes the post, but after that also a Get with the same method. This doesn't exists. MethodOne doesn't return any view and I don't want to GET MethodOne. I thought the JQuery post only did the function added as a parameter?
karl
I guess your controller action raises an exception and you are redirected to a custom page. Try calling it directly in your browser: `http://yourserver2k3/youapp/controller/MethodOne/5`. Activate tracing to see what exception is thrown.
Darin Dimitrov
Thanks. I'v found the problem. Had nothing to the JQuery post to do
karl
A: 

This is a good link http://support2.dundas.com/OnlineDocumentation/WebGauge2005/AJAXCallbackEvent.html, I tried Callback Events from this and it helped me to learn.

Ravia
Thank you for your reply
karl