I am trying to call a .php or .html file to display an input page for emails.

The file ContactDisplay.php contains a <button> to onclick a call to the sendEmail() function which, in turn, sends data to the file ContactEmail.html. The data is retrieved using $_POST and used to populate the <form> contained in ContactEmail.php.

Please see attached file.

The problem is: The form is not displayed nor is the result of print_r($_POST). The 'response' area of FIREBUG shows the total source code of the ContactEmail.php file.

I suspect this is the result of some stupid thing I've done but would appreciate some help in resolving the problem.

Thanks in advance, RP

Recommended Answers

All 4 Replies

Just posting to a PHP file doesn't show that page. The post function has a callback, which used, gives you the result of the page you post to. Then you can use Javascript/jQuery to do something with that. Have a look at the examples in the manual.

I'm confused (again).

In looking at the manual it givesa number of examples at least two of which imply that you don't need to have a callback function.

Examples: (from manual)

Example: Request the test.php page, but ignore the return results.

$.post("test.php");

Example: Request the test.php page and send some additional data along (while still ignoring the return results).

$.post("test.php", { name: "John", time: "2pm" } );

Example: pass arrays of data to the server (while still ignoring the return results).

$.post("test.php", { 'choices[]': ["Jon", "Susan"] });

Example: send form data using ajax requests

$.post("test.php", $("#testform").serialize());

Example: Alert out the results from requesting test.php (HTML or XML, depending on what was returned).

$.post("test.php", function(data) {
alert("Data Loaded: " + data);
});

Example: Alert out the results from requesting test.php with an additional payload of data (HTML or XML, depending on what was returned).

$.post("test.php", { name: "John", time: "2pm" },
function(data) {
alert("Data Loaded: " + data);
});

Example: Gets the test.php page content, store it in a XMLHttpResponse object and applies the process() JavaScript function.

$.post("test.php", { name: "John", time: "2pm" },
function(data) {
process(data);
},
"xml"
);

If I use a callback function like:

function () {

that's supposed to be:
function () {
return true;
}

Sorry, haven't found out how to edit this post.

R

Example: Request the test.php page, but ignore the return results.
$.post("test.php");


That is what you do, so anything that is echoed by the PHP file is ignored.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.