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



var response = $.ajax({ type: "GET",   
                          url : "http://www.google.com",   
                        async : false,
                      success : function(resp) {
                                    alert(resp);
                                }
               });



});

no output....

2 Answers 2

4

You are trying to break the "ajax same origin policy".

That means, you cannot access a foreign domain with an Ajax request. "Workarounds" are to use JSONP, HTML5 or CORS. All of those must be supported serverside.

The most common thing to solve this issue is, to use your webserver as a proxy. Let your server make the request and send the results back to your website.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you!. You have any idea about facebook displaying URL title and Meta description
0

I am not sure what you are trying to achieve but can try something like

$('#result').load('ajax/test.html', function() {
  alert('Load was performed.');
});

or have a look here http://api.jquery.com/load/

<!DOCTYPE html>
<html>
<head>
  <style>
 body{ font-size: 12px; font-family: Arial; }
 </style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<b>Footer navigation:</b>
<ol id="new-nav"></ol>

<script>
  $("#new-nav").load("/ #jq-footerNavigation li");
</script>
</body>
</html>

Update

If you know PHP you can try .. http://www.wait-till-i.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/

2 Comments

while giving local URL (eg: abc.html) it is working fine, But URL(abc.com) no output
Ok got it.. perhaps @jAndy's answer help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.