Solved

best way to post form data to seperate domain

Posted on 2010-08-25
4
544 Views
Last Modified: 2013-11-11
hi,

i have a form which needs to be posted to a web service on another domain.

doing a straightforward post action like this :

<form action="http://xxx.com/ContactsWs.asmx/ContactEx_Add" method="post" enctype="application/x-www-form-urlencoded" id="reg1">

works fine, but the successful result is posted as a piece of XML code, so for the user it really doesn't look very good...

i've been trying to post the data using jquery .post and ajax but i can't seem to get it to work...

can someone please provide me with a full working example for submitting the form cross-domain and displaying the xml results.... if i can get this response data it should be easy enough to display a success/failure message depending on the response...


0
Comment
Question by:dog_star
4 Comments
 
LVL 4

Expert Comment

by:darkyin87
ID: 33522732
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 33524543
You can't use AJAX, because of the javascript, to post to another domain.  The issue is "cross domain scripting" and browsers prevent it since it can lead to security issues and be used maliciously.Is the domain one you control?  Is it on the same server?  Using your own server page to do the work is an alternative.  For example if the page is php then using curl can be a way to have your page work with the page on the other server.  If you want details please let us know what language you can use.bol
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33524681
0
 

Author Closing Comment

by:dog_star
ID: 33541145
i wasn't sure if you could post cross domain with jquery ajax, and i guess you can't... which would explain why none of my attempt worked...

i ended up posting with PHP though it took me ages as i'm new to PHP....

thanks for the help and suggestions
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 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