English 中文(简体)
如何更新与 a子和 j子混凝土
原标题:How to update a specific div with ajax and jquery

I m working on site and it has a fram. think of the gmail frame. And much like the gmail app I want only the inner div to be updated when clicking links on the navbar. I ve got it so the div changes, but it certainly does not give me the results I m hoping for. this is a rough outline of what I have

<div id=container>
   <div id=page>
      ... some child divs in here
   </div></div>

由于该集装箱有固定的滚动条,我不想改变我只希望更换一页。 这是我设法在支部上走的。 我只是一个开端人,所以我不知道我做些什么,但我不想学习。

$(document).ready(function () {
    $.ajaxSetup ({
        cache: false
    });
    var ajax_load = "<img src= bin/pics/loading.gif  alt= loading…  width= 32px  height= 32px  style= top: 250px; left: 250px;  />";
    var loadUrl = "bin/ajax/load.html";
    $("#mybuton").click(function(){
        $("#page").load(loadUrl);
        location.hash =  ajax ;
    });
});

the load html contains this

<link rel="stylesheet" type="text/css" href="bin/main.css" />
<div id="page">
    <div id="child">
        <h1> sometitle </h1>
    </div>
</div>

任何建议?

最佳回答

http://api.jquery.com/jQuery.ajax/“rel=“nofollow”

《刑法》:

ajax_control = jQuery.ajax({
    url: "target.php",
    type: "POST",
    data: {variable_name: variable_value}
});
ajax_control.always(function(){
    $( #content ).html(ajax_control.responseText);
});

如果你想要的话,你可以通过使用:

ajax_control.abort();

http://api.jquery.com/jQuery.post/ http://api.jquery.com/jQuery.get/

问题回答

我不想回答链接,也不只是文字,因此,这里就是一个例子,说明你如何能够制造一个小块/板块或大部分是任何html集装箱,以改变其内容。

www.un.org/spanish/ecosoc 如果你与Razak一起重新使用MVC,那么就象这个。

<编码> 试验意见.cshtml

@using (Ajax.BeginForm("Test",
                       "TestController", 
                       new AjaxOptions {
                           HttpMethod = "GET",
                           InsertionMode = InsertionMode.Replace,
                           UpdateTargetId = "searchResults" }))
{
    Search User by ID: <input type="text" name="id" />
    <input type="submit" value="Search" />
}

<table id="searchResults">
</table>

public class TestController : Controller
{
    public PartialViewResult Test(int id)
    {
        var model = myDbContext.Users.Single(q => q.UserID == id);

        return PartialView("_PartialViewTest", model);
    }
}

@model IEnumerable<MyApp.Models.User>

<table id="searchResults">
    <tr>
        <th>Name</th>
        <th>Email</th>
    </tr>

    @foreach(var item in Model) {
        <tr>
            <td>@item.Name</td>
            <td>@item.Email</td>
        </tr>
    }
</table>

. 而且,如果你想利用传统的伙伴关系来做到这一点。 NET:

<编码> 测试Page.aspx

<body>
    <form id="form1" runat="server">
        <div>
            <button type="button" onclick= testCall() >Test!</button>
            <hr />
            <div id="ajaxResult">
            </div>
        </div>
    </form>
</body>

<编码>.js / TestPage.aspx

function testCall() {
    $.ajax({
        url: "TestHandler.ashx",
        dataType:  json ,
        success: callbackTestCall
    });
};

function callbackTestCall(payload) {
    document.getElementById("ajaxResult").innerHTML = payload;
};

Handler.ashx

public class TestHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        JavaScriptSerializer jss = new JavaScriptSerializer();
        Random random = new Random();

        string actualData = random.Next(2001).ToString();

        context.Response.ContentType = "text/plain";
        context.Response.CacheControl = "no-cache";

        context.Response.Write(jss.Serialize(actualData));
    }

    public bool IsReusable
    {
        // Whether or not the instance can be used for another request
        get { return true; }
    }
}

如果需要进一步信息,请让我知道。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签