1,105,214 Community Members

Result from $.post call is source code of page???

Member Avatar
pizzipie
Newbie Poster
20 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Attachments email_problem.html (3.15KB)
Member Avatar
pritaeas
mod_pritaeas
11,296 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

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.

Member Avatar
pizzipie
Newbie Poster
20 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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 () {

Member Avatar
pizzipie
Newbie Poster
20 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

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

R

Member Avatar
pritaeas
mod_pritaeas
11,296 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article