2

I send a request with AJAX to retrieve Html from a page like this :

 function getHTML() {
        //set ajax call
        var options = {
            url: '/Controller',
            type: 'GET',
            dataType: 'html'
        }
        //make call
        return $.ajax(options).then(querySucceded).fail(queryFailed);

        //handle theajax callback
        function querySucceded(data) {
            console.log(data);
            //THE NEXT LINE IS THE PROBLEME
            var val = data.getElementByName("somename").val();
        }

        function queryFailed(jqXHR, textStatus) {
            //var msg = 'Error getting data. ' + textStatus;
            console.log('Error while getting data');
        }
    }

so the ajax call works great and the querySucceded function is called, and the data is retrieved correctly.

but the data is considered as a string. how can I manipulate the DOM inside the data object using jquery, like:

$("somename").val();
4

3 に答える 3