Display AJAX communicated data via WordPress in header.blade.php on the laravel side

Asked 2 years ago, Updated 2 years ago, 86 views

The data (header and footer) that WordPress communicated with AJAX were displayed on the laravel side, respectively, but the source code below is not possible.Where is it wrong?

<iframe id="myiframe"src=""></iframe>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">  
letajaxUrl='https://example.jp/wp/wp-admin/admin-ajax.php';
$.ajax({
    type: 'POST',
    url —ajaxUrl,
    data: {
        action: 'get_header',
    },
    beforeSend: function(xhr){
          xhr.setRequestHeader("Authorization", "Basic"+btoa(ID+":"+password)));
     },

    success:function(data){
        variframe= document.getElementById('myiframe');
          iframe.contentWindow.content=data;
          iframe.src='javascript:window["contents"]';

    }
});`

laravel ajax

2022-09-29 22:28

1 Answers

In conclusion,

iframe.contentWindow.content=data;

This is

iframe.contentWindow.document.body.innerHTML=data;

Or

iframe.contentDocument.body.innerHTML=data;

I think so, but depending on the situation (this time, the destination server is the content of the content it will return), it is a risky implementation, so

https://developer.mozilla.org/ja/docs/Web/Security/Types_of_attacks

Read through this area and try it out!


2022-09-29 22:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.