Domanda

I'm fairly new to the programming world of Jquery. I am trying to get data from a web service to be viewed on a notification via Pnotify. However, on each page load the script does not view the notification bar. I really don't understand what I'm doing wrong. Hope you can help.

NOTE: the web service does retrieve the data correctly in JSON format.

UPDATED: I am able to do a msg.d but it retrieves the JSON but does not parse the information how I would like it to.

<script type="text/javascript">
$(function () {
    $.ajax({ //DATA REQUEST
        type: 'POST',
        url: 'WebServices.asmx/getNote',
        contentType: "application/json; charset=utf-8",
        dataType: 'json',
        success: function (msg) {
        $.pnotify({ //CALL PNotify 
        title: msg.NoteTitle,                               
        text: msg.NoteText
        });
       }                
    });
});
</script>
È stato utile?

Soluzione

I reviewed your code and if you do the following you should be able to get the data you need. You need to be aware that object that always need to be parsed before passing the array to a view. In your case you didn't do that.

 success: function (msg) {
               var Obj= eval(msg["d"]); or // $.parseJSON(msg["d"]) Method to evaluate Json

$.pnotify({ //CALL PNotify 
title: Obj["0"].NotificationText, // The pared arrays
text: Obj["0"].NotificationDescription
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top