Web Api+ajax

  • 36
  • 0

Web Api+ajax

<ul class="info">

</ul>

function () {
        var jqxhr = $.post('http://127.0.0.1:9000/api/remote', { "uuid": $('#UUID').val(), "RSSI": $('#RSSI').val(), "messageBridge": $('#messageBridge').prop('checked') })
            .success(function (data) {
                var jsonObj = $.parseJSON(data);//如果是json字串要轉成json物件
                $('.info').empty();
                    $.each(jsonObj, function(index, element) {
            $('.info').append(
                    $('<li>', 
                    {text: [index+1]+'.'+'名稱:'+element.msg}),
                    $('<p>')
                    );
        });

              //  console.log(data)
            })
            .error(function () {
                $('#message').html("Error posting the update.");
            });