-6

Not sure what I'm missing? trying to get html from remote domain (I know about cross domain ext...) but this as worked in the past...

Can't see where I'm going wrong:

CODE:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <link href="http://jqmdesigner.appspot.com/gk/lib/jquery.mobile/1.4.2/flatui/jquery.mobile.flatui.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js">     </script>
    <title>get the html from a website</title>
    <script>
$( document ).ready(function() {            
$.get("https://www.miemssalert.com/chats/Default.aspx?hdRegion=5",  function(data) {
            $(".ui-content").html( data );
            alert( "Load was performed." );
        })
            .done(function() {
                alert( "second success" );
            })
            .fail(function() {
                alert( "error" );
            })
            .always(function() {
                alert( "finished" );
            });
});
    </script>
</head>    
<body>          
<!-- Page: home  -->
    <div id="home" data-role="page">
        <div data-role="header" data-position="fixed" data-theme="b">
        <h3>GET WEB DATA</h3>
        </div>
        <div role="main" class="ui-content"> 
        </div>
    </div>           
</body>

BarclayVision
  • 865
  • 2
  • 12
  • 41

2 Answers2

2

You are missing the document ready:

$( document ).ready(function() {
     $.get( .....

});

Since the ui-content div isn't loaded yet there is no place to display the data.

jtheman
  • 7,421
  • 3
  • 28
  • 39
0

The URL in $.get seems to be unavailable. Just open it in a browser and see that it does not give you a result (or answer at all). That's probably why the code has been working before.

Kristoffer Jälén
  • 4,112
  • 3
  • 30
  • 54
  • The URL https://www.miemssalert.com/chats/Default.aspx?hdRegion=5 is working fine. – jtheman Jun 24 '14 at 20:37
  • Now it is. It wasn't before, for me atleast. Hopefully the code is working now. – Kristoffer Jälén Jun 24 '14 at 20:38
  • no not working and URL has been tested several times... – BarclayVision Jun 24 '14 at 20:43
  • I do see a cross domain error in firebug on firefox browser, but like I said, I have used the same code in mobile phone gap projects to get remote html with no problem... Safari Browser has always worked. – BarclayVision Jun 24 '14 at 20:45
  • @BarclayVision the fact that it works in another browser doesn't change the fact that you have a cross-domain error. Most likely your CORS setup is incorrect. – Kevin B Jun 24 '14 at 20:46
  • not sure what you mean by "my" CORS setup? wouldn't that be on the remote server that I don't have access too? – BarclayVision Jun 24 '14 at 21:03
  • 1
    Yes, it would be on the remote server. So, "their" instead of "your" I guess. Can you open the network tab and post the response headers in your question? – Kevin B Jun 24 '14 at 21:08
  • Actually, don't bother, i just tested it from a VM and confirmed the problem. The remote server is not returning CORS headers. You will not be able to retrieve the data with client-side javascript alone from that url. – Kevin B Jun 24 '14 at 21:11