Ok, this question probably has been asked quite a number of times, but I am fairly new to this technology and am not sure of what I should search for. So, if someone could either point me to a link where it has already been answered or provide the answer here, I would appreciate it.

Here is what I am trying to do.
On my web page, I have three choices for the user to pick from. After the user selects one of the checkboxes and clicks a submit button, I need to send a http request to a remote server to record the user's choices (actually it is an https that I am sending),.. so I need to send something like this.

htpps://otherserver.net/theScript.aspx?parm1=blahblah

The remote server responds with an xml response that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<sessionState>
<answer>True</answer>
</sessionState>

So, I want to post the request, read the response (answer) back from the other server and display it on my page. So, my dilemma is as follows:

1) my understanding is that I cannot do this with AJAX using an XMLHttp object because it is on a remote server and it would violate some sort of same-domain security. Is that correct? If in fact I can do it in AJAX, how do I read the response back from the other server?

2) if I am correct in my assumption in 1) then what is the best way to accomplish this task?

Thanks in advance for any assistance anyone can provide.

You would setup a server-side script (using PHP or ASP or whatever your language is) that uses cURL or whatever your language uses to make and output the response. Then your AJAX call just points to your script.

RemoteServer
-------------------
somefile.php

MyServer
-----------------
myapifile.php
`- Make request to RemoteServer.com/somefile.php
`- Output response from the request

myawesomeajax.js
`- Make request to myapifile.php

Thanks, I will give that a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.