tags:

views:

144

answers:

2

i want to call page content using $.get method that will call a page(.ascx) and render page content into div in current page(aspx) i have used something like this... didin't work..

<script type="text/javascript">
function calltemp1() {
  var result = '';
  $get("/Views/Templates/_Temp1.ascx",result)
  $("#RecentstoryDiv").html(result);
}
</script>

above script gives jscript runtime error "object expected".

+2  A: 

use the load() function instead

$("#RecentstoryDiv").load('/Views/Templates/_Temp1.ascx');

See the documentation here: http://docs.jquery.com/Ajax/load#urldatacallback

Christian Dalager
thanks for reply i have tried above code but it produces following error"Microsoft JScript runtime error: Object expected"my partial "_Temp.ascx" page contents:<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %><%Html.RenderPartial("/Views/Templates/Temp1.ascx"); %>does this has something to do with the error??please reply
dexter
+1  A: 
  1. You should be using $.get and not $get
  2. Your call to $.get is missing its ending semi-column
  3. Second parameter to $.get is a callback, not a variable to be filled. You need to pass a function that will be passed the content as a parameter

Here is a working example:

$.get("/Views/Templates/_Temp1.ascx", function(result)
{
    $("#RecentstoryDiv").html(result);
});

But you will be better using the load method

$("#RecentstoryDiv").load("/Views/Templates/_Temp1.ascx");
Vincent Robert
i have tried above example but it gives follwing error" Microsoft JScript runtime error: '$' is undefined "what might be the reason .??pls pls replay..
dexter
Can you add to your answer the code you are using to include jQuery in your page?
Vincent Robert