We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Can jquery ajax be used in iframe inside runcode() in js file?

Home Forums Programming Can jquery ajax be used in iframe inside runcode() in js file?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #50573
    derekwang0605
    Customer

    When I tried to add the above inside runcode(), it always pop up an error which can not access the json file. Not sure why? It usually works well if not using iframe.
    $.ajax({
    url: “datainfo.json”,
    type: “GET”,
    dataType: “json”,

    success: function(data) {

    json_data=JSON.parse(data)

    console.info(json_data[‘object’])
    $.each(data, function(i, item) {
    console.log(i,item);
    if(item.object == clickname.name){
    parent.document.getElementById(“obj-name”).innerHTML = 1;
    parent.document.getElementById(“obj-id”).innerHTML = 404;
    parent.document.getElementById(“obj-price”).innerHTML = item.object;
    }
    })
    },
    error:function (msg) {
    console.log(msg);
    //alert(‘system error’);
    }

    });

    #50581

    hi,

    it may be a cross-origin issue – both HTML files must be served from the same domain for JavaScript to work between them

    Chief 3D Verger | LinkedIn | Twitter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.