Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
XML does not render after making an ajax call

I am trying to make an ajax call and on the server accessing a field from the table I have the following:

<PushProperty><Status ID = "1"> Success </Status><ResponseID> b3633c9eeb13498f </ResponseID><ID> 9098 </ID></PushProperty>

I want this result to be displayed with its respective format and labels and I cannot get it.

In the controller I have the following:

class RequestResponseController extends Controller
{
    public function show_data(Request $request){

        $rr = RequestResponse::find( $request->id);

        $text = $rr->response;

        return $text;

    }
}

And from view I call it with ajax:

function show_request_response (id, type) {

    $.ajax ({
        url: "/request_responses/show_data",
        data: {
            "_token": "{{csrf_token ()}}",
             "id" : id,
            "type": type,
        },
        method: "POST",
        async: false,
        success: function (xmlResponse) {

            $ ('# exampleModal'). modal ('show');
            $ ('# exampleModal .modal-title'). html ("Response XML");
            $ ('# exampleModal .modal-body'). html (xmlResponse);

        }
    });
    return false;
}

But in the modal it shows me only text without xml tags, that is:

Successb3633c9eeb13498f9098

But I need to get:

<PushProperty>
     <Status ID="1">Success</Status> 
     <ResponseID>b3633c9eeb13498f</ResponseID> 
     <ID>9098</ID>
</PushProperty>

I hope it helps me thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're using jQuery's html() method which tells it to parse the input as HTML.

In HTML <this> is a tag and isn't rendered as plain text.

Use the text() method if you want to tell jQuery to render the input as text instead of HTML source code.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!