简体   繁体   English

有人可以解释一下这个javascript代码(与ajax有关)吗?

[英]Can someone please explain this javascript code (related to ajax)?

I am a little confused as to what the function below does.我对下面的函数的作用有点困惑。 Would someone be able to explain the steps once "id" and "data" are entered?输入“id”和“data”后,有人能够解释这些步骤吗?

function LoadPlayer(id,data) {
    $.ajax({
        url:Player,
        method:"POST",
        data:{id:id,data:data}}).done(function(result{
            $('#'+id).html(result);
    });
}

It send a POST request using ajax, with Player object as its URL.它使用 ajax 发送 POST 请求,并将 Player 对象作为其 URL。 The body data has an object with properties id and data.正文数据有一个具有 id 和 data 属性的对象。 Once the ajax request is successful, it finds a dom element with ID id and writes its result from the request there.一旦 ajax 请求成功,它就会找到一个 ID 为 id 的 dom 元素,并将请求的结果写入那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM