August 7, 2010

jQuery ajax load html from another server

Question by StealthRT

Possible Duplicate:
Load website into DIV

Hey all i am trying to find a way to call an external website and retreve its HTML so that i can check for something in it (wither the user entered a valid VIN # or not depending on what this website calls back)

This is the code i have:

$.ajaxSetup ({

  cache: false
 });

 $("#load_callback").click(function(){
    $.ajax({
    url: 'http://www.google.com',
    dataType: 'text',
    success: function(data) {
   alert(data);
    }
  });
 });

It works but only if i have it pointed to my server (and running on my server also). Is there a way i can call an external website using jquery/ajax? I am aware of the Same origin policy but was hoping something like what i want to do did not fall into that catagory?

I cant even get an iFrames title? Really??? wow….

David

Answer by Starx

Stick to simple things, if you want to load websites, be simple and go with iframe. If you want to make request use PHP or similar. For example you can use curl method to make request to another websites through PHP. Or even simpler, setup a form to request to another web server.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!