tags:

views:

70

answers:

3

I would like to using (Ajax) PHP or Javascript, Post information to http://en.lernu.net/cgi-bin/vortaro.pl then read the results back (Not from lernu.net).

I am trying to learn Ajax, PHP + Javascript, Nobody there know's how to help me. I would very much like doing this without touching Lernu's code, So if there is a way to do it all on my code, that would be great!

A: 

You need to write a PHP script in your domain that forwards your POST to http://en.lernu.net/cgi-bin/vortaro.pl, then forwards their response back to the client.

You can then send an AJAX POST to your server with jQuery.

SLaks
Well thank you, I have read how to do a php redirect page, But a google search on php forwarding does not come up with anything useful. can you please be a little more detail. maybe a link or some code, Thank you very much
Klanestro
+1  A: 

You need to proxy the request due to browsers preventing cross-domain ajax calls.

You can either do this with a PHP page on your site or configure url rewrite rules for your webserver.

slebetman
A: 

You maybe able to do a simple post to your url with jquery in following ways:

 $.ajax({
   type: "POST",
   url: "http://en.lernu.net/cgi-bin/vortaro.pl",
   data: "name=John&age=21",
   success: function(msg){
     alert( "Data Posted to server: " + msg );
     // you may additionally call other javascript methods here to do modifications to your page based on your request
   }
 });

Jquery is an excellent framework for javascript and I would highly recommend using it for most of your functionality. You might want to readup a bit about javascript and then start up with jquery.

Priyank