Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7179113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:04:28+00:00 2026-05-28T17:04:28+00:00

Can I use $.ajax() to send POST to PHP file on other domain? A

  • 0

Can I use $.ajax() to send POST to PHP file on other domain? A have a error message in $.ajax(). In Chrome or Firefox – email send. In IE – email is not send.

This is HTML file

<form name="order" method="post"action="http://www.site.ru/images/stories/controller.php">
<label>1. Mark*:</label>
    <select name="mark" class="inputbox">
        <option ="selected"></option>
        <option>Audi</option>
        <option>BMW</option>
    </select>
<label>2. Model*:</label>
    <input type="text" name="model" size="30" class="inputbox"/>
<label>3. Year*:</label>
    <select name="year" class="inputbox">
        <option ="selected"></option>
        <option>2011</option>
        <option>2010</option>
    </select>
<label>4. Value, l*:</label>
    <input type="text" name="value" class="inputbox" size="30"/>
<label>5. Transmission*:</label>
    <select name="transmission" class="inputbox">
        <option ="selected"></option>
        <option>Manual</option>
        <option>Automatic</option>
    </select>
<label>6. VIN:</label>
    <input type="text" name="vin" size="30" value="" class="inputbox" maxlength="17" />
<label>7. E-mail*:</label>
    <input type="text" name="email" size="30" class="inputbox" />
<label>Note*:</label>
    <textarea cols="50" rows="5" name="text" id="contact_text" class="inputbox"/</textarea>
<input type="button" value="Send" onclick="valid();"></input>
</form>

<script src="http://admin.abcp.ru/common.jscripts/jquery/jquery-1.6.2.min.js"></script>
<script language="JavaScript" type="text/javascript">
function sendEmail(mark, model, year, value, transmission, vin, email, text){
    $.ajax({
        url: "http://www.site.ru/images/stories/controller.php",
        type : "POST",
        data : {
            mark : mark,
            model : model,
            year : year,
            value : value,
            transmission : transmission,
            vin : vin,
            email : email,
            text : text
        },
        success: function(){
            alert('Success.');
        },
        error : function (){
            alert('Error.');
        }
    });
}
</script>
<script language="JavaScript" type="text/javascript">
function valid(){
if (document.order.mark.value == ""){
    alert("Mark is empty.");
    document.order.mark.focus(true);
    return false;
}
if (document.order.model.value == ""){
    alert("Model is empty.");
    document.order.model.focus(true);
    return false;
}
if (document.order.year.value == ""){
    alert("Year is empty.");
    document.order.year.focus(true);
    return false;
}
if (document.order.value.value == ""){
    alert("Value is empty.");
    document.order.value.focus(true);
    return false;
}
if (document.order.transmission.value == ""){
    alert("Transmission is empty.");
document.order.transmission.focus(true);
    return false;
}
if (document.order.email.value == ""){
    alert("E-mail is empty.");
document.order.email.focus(true);
    return false;
}
if (document.order.text.value == ""){
    alert("Text is empty.");
document.order.text.focus(true);
    return false;
}
sendEmail(document.order.mark.text, 
    document.order.model.text,
    document.order.year.text, 
    document.order.value.text, 
    document.order.transmission.text,
    document.order.vin.text,
    document.order.email.text, 
    document.order.text.text);
}
</script>

This is PHP file controller.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Обратная связь</title>
</head>
<body>
<?php
$from = $email;
$to = "pinaza@avt59.ru";
$subject = "PINAZA.RU - Запрос по $mark";
$message = "Марка автомобиля: $mark \nМодель автомобиля: $model \nГод выпуска: $year \nОбъем двигателя, л: $value \nТип КПП: $transmission \nVIN-код: $vin \nНеобходимые детали:     $text";
$headers = "Content-type: text/plain; charset = utf-8";
mail("$to", "$subject", "$message", "from: ".$from."\r\n"."$headers");
?>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:04:30+00:00Added an answer on May 28, 2026 at 5:04 pm

    You cannot use ajax to post to different domain.

    Refer: http://en.wikipedia.org/wiki/Same_origin_policy

    You can use proxy instead.
    Post this data to your php/asp.net file (which resides on same domain) and from that php/asp.net file post data to another domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use $.post('ajax/test.php', function(data) { $('.result').html(data);}); to send data and retrieve information and show
Can I have good example or code about how to use Ajax Datepicker in
I have an AJAX call in my jQuery/PHP app. It needs to send some
I'm trying to use $.ajax to send some values to a php page which
Let's imagine that we have something like: $.post('somescript.php', 'WHAT CAN WE PUT HERE?', function(replyData)
In the Ajax toolkit you can use a Tab Container and add TabPanels to
I am starting to use the jquery $.ajax() but I can't get back what
I already search about this and I cannot use ajax in file uploading, but
I am trying to send a form to a PHP file via jQuery. The
I have a view_mine_and_others.php file that outputs this html <div class=rec id=1> <div class=val>343</div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.