简体   繁体   中英

Acces an object member with each function

I have a problem and I can't resolve it. So I have returned from controller to view objects, my .js code is :

<script>
    $('#suppliers').change(function () {
        var id = $("#suppliers option:selected").val();
        url_deploy = "http://"+window.location.hostname+"/gestion_dotation/getSupplier";
        $.post(
                url_deploy,
                {id_supplier: id},
                function(result) {
                    $.each(result, function () {
                        console.log(result);
                    })
            });
    });

</script>

If I do console.log(result) I get :

[[Object { ref_article="1903",  ref_f="sdsds",  lien="www.four.com"]]

Now how to acces this members : ref_article,lien ? I tried this.ref_article but not work. Can you help me please? Thx in advance

You can access object members using Property accessors .

$.each(result, function(key, value) {
  console.log(value.ref_article);
});

jQuery .each() documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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