1

I'm currently trying to make some ajax post between cross-domains by following this tutorial but something wrong some data wasn't send.

Actually my proxy script is a copy of the tutorial and this my javascript :

$.ajax({
    type: 'POST',
data: data + '&origin=' + origin, 
url: 'customer.php', 
dataType: 'json',
async: false,
success: function(result){
    if (result.id && result.quotation_id){
        id = result.id;
        quotation_id = result.quotation_id;
    }
    }
});

1 Answer 1

1

Solved by making a php script with curl :

//set POST variables
$url = 'http://my-different-domain.com';

$fields = array();

foreach ($_POST as $key => $value) {
    $fields[$key] = urlencode($value);
}

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.