dexter
dexter

Reputation: 1207

using $.get to get page content and render it into div tag

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".

Upvotes: 0

Views: 2326

Answers (2)

Vincent Robert
Vincent Robert

Reputation: 36130

  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");

Upvotes: 2

Christian Dalager
Christian Dalager

Reputation: 6643

use the load() function instead

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

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

Upvotes: 2

Related Questions