1

I need help forwarding html form content to public http service if someone can explain how this can be done or where to find a tutorial for this would be great!

I have my form made as you can see below:

<span class="text"> <input class="text" type="text" name="First" value="First" ></span>
                <span class="text"> <input class="text" type="text" name="Last" value="Last" ></span>
                <span class="text"><input type="text" value="Email" /></span>
                <input class="btn-submit" type="submit" value="Submit"  />   

I was given the following code to forward the input:

$.ajax({
    url: 'https://www.saddleback.com/Services/Subscription/Subscription/Save/' + subscriptionId,
    data: {
        'firstName': firstName,
        'firstName': firstName,
        'lastName': lastName,
        'email': email,
        'redirectToUrl': redirectToUrl,
        'redirectFailureToUrl': redirectFailureToUrl
    },
    type: "post",
    cache: false,
    dataType: "text",
    success: function (message) {
        $('.subscriptionWarning').append("<span id=''litStatus''>" + message + "</span>");
    },
    error: function (xhr, ajaxOptions, thrownError) {
        $('.subscriptionWarning').append("<span id=''litStatus''>Error encountered while saving subscription.</span>");
    }
});

The ID I needed to forward it to is 23

Thank you for the help and sorry if my question was phrased wrong.

    <span class="text"> <input class="text" type="text" name="firstName" value="First" ></span>
                <span class="text"> <input class="text" type="text" name="lastName" value="Last" ></span>
                <span class="text"><input type="text" name="email" value="Email" /></span>
                <input class="btn-submit" type="submit" value="Submit"  />       








$fname = $_GET['firstName'];
$lname = $_GET['lastName'];
$email = $_GET['email'];

$h = curl_init();

curl_setopt($h, CURLOPT_URL,           "http://profile.purposedriven.com/managesubscriptionssimple.aspx");
curl_setopt($h, CURLOPT_POST, true);
curl_setopt($h, CURLOPT_POSTFIELDS, array(
'name' => 'yes',
'comment' => 'no'
));
curl_setopt($h, CURLOPT_HEADER, false);
curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($h);
echo $result;

Thats what my code looks like now.

jrojas
  • 39
  • 6
  • are you trying to submit the form to a different website? – Ibu Oct 12 '12 at 17:44
  • Yes to http://profile.purposedriven.com/managesubscriptionssimple.aspx – jrojas Oct 12 '12 at 18:08
  • wait... what site are you trying to submit this form to? – mk_89 Oct 12 '12 at 18:15
  • We are trying to submit a form from our dev site, to the form located here - http://profile.purposedriven.com/managesubscriptionssimple.aspx by passing the information through on the backend. Our dev site is PHP while the site that the information needs to be passed to is aspx – jrojas Oct 12 '12 at 18:18

1 Answers1

0

You won't be able to make an ajax request to an website with a different domain.

Read more here: Why Cross-Domain AJAX call is not allowed?

How ever you can make the request in your own server using php and cURL or file_get_contents

Example: Submit your form in your own website than:

$fname = $_GET['firstName'];
$lname = $_GET['lastName'];
$email = $_GET['email'];

And follow cURL from the manual here

Community
  • 1
  • 1
Ibu
  • 42,752
  • 13
  • 76
  • 103