2

I'm trying to return some information from an .ajax function but I'm having trouble extracting the data I need from the requested page .ajax function looks like this:

$.ajax({
          type: 'get',
          async:   false,
          url: "www.site.com",
          success: function(Data) {
            return Result = $(Data).filter('#ReturnedInfo');
          },
          error: function(Data) { 
            return Result = "no"; 
          }

        });
      $('#ShowReturned').append("Start"+Result+"end");

Yet on the page all that is being appended is Start[object Object]end or null, depending on the method I choose. (returning Data itself successfully appends the entire page)

I've had a look at some other questions on the site that seem to be having similar problems but none of the solutions appear to work.

Any help is greatly appreciated.

1 Answer 1

1

Try this

Result = $(Data).find('#ReturnedInfo').get(0);
var container = document.createElement("div");
container.appendChild(Result.cloneNode(true));

$('#ShowReturned').append("Start"+container.innerHTML+"end");

Tis is a workaround but this should solve your purpose.

Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks. This does work. For simplicity's sake I've just moved the part of the document I'm trying to retrieve to the top, and have ended the response once done so. Then I can just return the entire page as-is. The joys of ADODB and .ASP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.