getting data as the page loads

I'm trying to get data back after an element is ready in the DOM. I'm trying to use the load function from JQUERY but I get a message .load() is not a function. Is there a best practice when using ajax to get data for an element (in my case a div) during a page load? I'm using ASP.NET and calling a webmethod in code behind. Here is my ajax/jquery code: $(document).ready(function () { $(function () { $("[id$=divArea]").load()(function () { $.ajax({ type: "POST", url: "apage.aspx/Role", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function (response) { alert("got data from Role"); }, error: function (data) { alert("failed to get data from Role"); } }); }); }); Thanks.
.load only works on elements that actually load something such as iframes images and the window. what are you actually trying to do?

以上就是getting data as the page loads的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准