jeudi 13 août 2015

AJAX request to PHP - Handling response data

Im working on some AJAX login function, making a request via PHP. I am wondering how do I return data via the PHP so that I can handle it like the code mentioned below. I only worked on the javascript side and not the PHP server side so I am confused now.

I want to get a value/values stored in the response like data.name , data.sessionID , data.listOfnames

Is the data a JSON Object by itself? Thanks!

The code below was used before and has been verified to work.

function retrieveVersion(){
                                var URL = RSlink + "/updates";
                                $.ajax({
                                        headers : {
                                                "Content-Type" : "application/json; charset=UTF-8",
                                                "sessionid" : result
                                        },
                                        type : "GET",
                                        url : vURL,

                                        statusCode : {
                                                0 : function() {
                                                        hideLoadingMsg();
                                                        showError(networkError, false);
                                                },
                                                200 : function(data) {
                                                        currentVersion = String(data.version);
                                                        updatesArray=data.updates;
                                                        });
                                                        
                                                        }
                                                }
                                        });​


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire