由于HTML标签的iframe标签具有局部加载内容的特性,所以可以使用其来伪造Ajax请求。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<input type="text" id='url'>
<input type="button" value="发送iframe请求">
<iframe id="ifm" src="http://www.baidu.com"></iframe>


<form action="/xiaoqing/ajax_json/" method="post" target="ifm1">
    {% csrf_token %}

    <iframe id="ifm2" name="ifm1"></iframe>
    <input type="text" name="username">
    <input type="text" name="email">
    <input type="submit" onclick="submitForm();" value="Form提交" >

</form>

<script src="/static/jquery-1.12.4.js"></script>
<script>


        $(function () {

            $(':button').click(

                function () {
                    var url=$('#url').val();
                     $('#ifm').attr('src',url);

                }
            )


        })

       function submitForm() {

           $('#ifm2').load(function(){

            var text= $('#ifm2').contents().find('body').text();  #这个地方要注意
            var obj= JSON.parse(text);
              console.log(obj);
           })

       }




</script>

</body>
</html>
iframe.html

相关文章:

  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-06-08
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
猜你喜欢
  • 2021-09-03
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-05-25
相关资源
相似解决方案