Ajax form on Client sent to another Server

Posted on 2009-02-12
Last Modified: 2013-11-19
I need to create an Ajax widget for my resellers where a user can have fill out a form on the client website and post the resulting form to  my server via Ajax.

Example: on I want a user to click on Add Product.
Add product will dynamically construct an HTML form which is on
The user needs to ALWAYS be on

In other words, will load the form which is on  The user will ALWAYS be on

In other words, will just read in
--- Contents of
// Send the form results
function ajax_post() {}

<form action="javascript:ajax_post" method=GET>
Username: <input type=text name=username><br>
ProductID: <input type=text name=productid><br>
Question by:pmsguy
    LVL 18

    Assisted Solution

    Ajax will not work cross domain.  Ajax request can only be sent/received on the same domain.   If you want to do cross domain ajax, you need to make your request to a script on the same server, and have that script act as a proxy to the other domain.  Thinks like curl in php, httpwebrequests in asp and lwp in perl, etc are needed for this.

    Author Comment

    Do you have any examples on how to accomplish this cross domain process?

    I want my clients to install this widget.  I do not want them to have to put any code on their server.
    I have no idea if they have PHP, ASP, .. as their server code.

    How would I accomplish this?  Do they have to be redirected to my server to fill out the form and I can use ajax to send to my server and when done redirect them back to the original client site?
    LVL 18

    Accepted Solution

    If site A wants to get data from site B, then site A cannot get it through ajax(or client side scripting) alone.  This is a violation of the security protocols established for the XMLHttpRequest object.  "Ajax" requests can only be made on the same domain.

    The work around is: sends a ajax request to
    serversidescript.ext does an http request(similar to an ajax request, but done on the server side, where permissions are usualy capable of doing these requests) on the server to outputs the results that it gets from  So you know have the data from another site, but you are still making ajax request to the same domain.

    If is the client site, then the only way they would be able to contact your site via ajax is to have a "proxy" script(a script on the server that makes an http request to your site and returns the results) handle the requests.

    Author Closing Comment

    I used an IFRAME scenario to accomplish this goal.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now