views:

65

answers:

3

Hi

I have two strongly-typed partial views (Developers list and Testers list) and the respective views are Developers.ascx and Testers.ascx

Now I want to load one partial view based on the radio button selected. The below code is not loading the URL that I specified on radio button change.

Code Snippet:

$(':radio').click(function() {

alert(this.value);
var url = '/Home/Developers/';
if (this.value == '2') {                 
     url = '/Home/Testers/';
}

 $(".Inquiries").load(url);

});

I would appreciate if anyone can provide a code snippet to load strongly-typed partial view from jQuery.

Thanks

Rita

+1  A: 

I will go with a generic answer that will help you in many situations - get FireBug, and

  • on Net pane check that request is sent, and what is the answer from the server
  • on Scripts pane set breakpoints in your script to see if its called
  • on Console pane do both check js errors and ajax calls
  • and so on
queen3
+1  A: 

You code sample worked fine for me, I think the problem is either you need to add it inside of a document ready function or it might be you need to include the file name

$(document).ready(function(){
 $(':radio').click(function() {
  alert(this.value);
  var url = '/Home/Developers/Developers.ascx';
  if (this.value == '2') {
   url = '/Home/Testers/Testers.ascx';
  }
  $(".Inquiries").load(url);
 });
})
fudgey
A: 

Hmm... It is still not working? I tried by adding inside of a document ready function and by including the file name as well.

Am i missing any separate Developers and Testers actions code on the main viewpage?

Rita
If your target pages are complete web pages (include `<html><body>` etc). Then you should target the contents of the page (see docs: http://docs.jquery.com/Ajax/load#urldatacallback).
fudgey