Solved

best way to post form data to seperate domain

Posted on 2010-08-25
4
545 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

839 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