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.
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.