0

I would like to load page into <div> but I'm running out of ideas. Getting all kind of errors depending of my attempt (mostly Cross-Origin Request Blocked ), so, obviously this is not the way.

this $("#cmbsHost option:selected").text() contains IP, lets say: 139.131.4.5

My last tries:

$.ajax({
    type: 'POST',
    url: "http://ip-api.com/#" + $("#cmbsHost  option:selected").text(),
    crossDomain: true,
    //dataType: "jsonp",
    dataType: 'html',
    cache: false,
    success: function (data) {
        console.log(data);
    }

and of course this one:

$("#dlgWhois").load("http://ip-api.com/#" + $("#cmbsHost  option:selected").text());

So... how to do it sensei?

dllhell
  • 1,987
  • 3
  • 34
  • 51

2 Answers2

0

You need to load the full page, and then find the element/text inside the data loaded.

$.ajax({
    type: 'POST',
    url: "http://ip-api.com/#"
    crossDomain: true,
    //dataType: "jsonp",
    dataType: 'html',
    cache: false,
    success: function (data) {
        console.log( $(data).find("#cmbsHost option:selected").text() );
    }
});
sandrina-p
  • 3,794
  • 8
  • 32
  • 60
0

make sure that url is right with right query string parameter

 $.ajax({
                url: "http://ip-api.com?ip=" + $("#cmbsHost  option:selected").text(),
                dataType: 'html',
                type: 'GET',
                success: function (data)
                {                    
                    $("#dlgWhois").html(data);
                }
            })
Raju Mali
  • 185
  • 4