A LINK I can directly acces...">

Get html across domains using jQuery and JSONP

I have a form that outputs one simple html line <a href="link">A LINK</a>

I can directly access the process with data added to the URL, for example http://site.com/form.asp?sample=100

Since this happens across domains (in a subdomain), I am trying to do this using JSONP. I tried it first with datatype json, but I still got a ban on 403. That's what I'm trying to use with JSONP, but it's all messed up and returns an error with this% 5Bobject% 20Object% 5D added to it. I think this is a problem with how I try to add data to url?

$j.getJSON({
        type: 'POST',
        url: 'http://site.com/form.asp',
        data: 'order=' + ordervalue,
        contentType: "application/json; charset=utf-8",
        dataType: "jsonp",
        success: function(response) {
            alert(response);
        }
    });
+3
source share
2 answers

JSONP , JSON, HTML.

JSONP - GET ( <script>), POST ... . JSONP, :

<script type="text/javascript" src="http://site.com/form.asp?order=something&callback=myFunc"></script>

.... JavaScript, , :

myFunc({ "key": "value"...data, etc... });

HTML, , ( ).

+7

/ - :

flyJSONP/YQL
jankyPOST/PostMessage/contentWindow
CORS

+1

Source: https://habr.com/ru/post/1776646/


All Articles