views:

103

answers:

2

Hi all,

I currently have the following within my view

function loadData() {
     var url = "/Testx.mvc/GetData";
     var id = "111111";
     var format = "html";

     $.ajax({
         url: url,
         type: "POST",
         dataType: format,
         data: "id=" + id,
         success: populateResults
     });
 }

 function populateResults(result) {
     $('#results').html(result);
 }

I also have a controller called TestxController with an action method called GetData(int? id). Now the ajax call above works on Visual Studios 2008's built-in development server, but when i switch it to use IIS webserver it doesn't. It seems like the route isn't being found because I tried putting a break point on GetData but it doesn't even reach there. Does anyone know what i would need to do to fix this?

Edit: I've also tried the wildcard mapping method discussed at http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx and it worked perfectly. (Of course I had to remov the .mvc from the url) Is there any way to get this to work with the .mvc extension?

Thanks

A: 

Is there an actual function called 'callback'? Just asking because it seems like you might mean to be calling 'populateResults' with a successful response.

Try this perhaps:

$.ajax({
     url: url,
     type: "POST",
     dataType: format,
     data: "id=" + id,
     success: function(results){$('#results').html(result)}
 });

Did you check your ISS setup to see if it supports the POST action? It might only be specifying the GET action... see http://haacked.com/images/haacked%5Fcom/WindowsLiveWriter/07de283cb368%5FB754/application-mappings%5F3.png

Ambrosia
oh nevermind, seems you fixed that in an edit
Ambrosia
yeah sorry about that
zSysop
Yeah that didn't change anything. Thanks though
zSysop
+1  A: 

Is Testx.mvc at the root of your webserver? If your application is running in a virtual directory on IIS then the correct path would be something like /YourApp/Testx.mvc/GetData.

The Visual Studio built-in webserver might be placing Testx.mvc at root, which is why it works within VS.

If that is the case, then try using the relative path Testx.mvc/GetData rather than /Testx.mvc/GetData.

ctford