php – How to do a jQuery $.ajax or $.get request on a distant/other server? No Json or JSONP – Education Career Blog

I’m working on a little widget that will allow to embed like an iframe (but with a jQuery plugin) a part of my website.

I’ve successfully made a search.php API that produces in JSONP what I need to retrieve. It works! (thx to this community 😉 ). I had difficulties to understand and use right callback request to allow a distant server to retrieve info on mine.

Now, I’d like to do the other way of interracting: writting :ask a question, vote for an answer.. I’ve made pages that accept GET parameters to do that.

For example, if I call myserver.php/vote.php?id_vote=xxx I add a vote to the answer xxx in my database, and return 1 ok status. But it appears to work not as easily as if I were on my server..

How can I call this vote.php page on another server, using jQuery and $.Get or $.ajax?

Thanks a lot

,

You can perform your Ajax call on a php page which contain

echo file_get_contents('url');

But you need to have allow_url_fopen activated.

,

I’ve solved my problem, in fact, I used the same way as in this thread:

How to make a search.php API

I return my 0 or 1 status in JSON and make a correct JSON ajax call.

Leave a Comment