On 23 Jun 2011 at 14:56, Ethan Rosenberg <eth...@earthlink.net> wrote: 

> At 05:21 PM 6/22/2011, you wrote:

>> 2) Instead of doing alert("yippee"), seems to me you should alert on
>> the results of the ajax call. I don't know how you get at those with
>> jquery, but I imagine that is where you'll find the results of doing
>> var_dump($_POST);

> The results should be in $_POST. I have done a print_r and var_dump
> and nothing is there.  My question was if the call ever worked.

But you don't know that nothing is there because you haven't looked for the 
output.

When an ajax call is made, it causes a script on the server to be run. You tell 
the ajax call what script you want to have run, in this case apparently 
jq_test.php. All output from that script will be returned to the function you 
specify in the ajax call. As I said, I don't know jquery, but I'm guessing that 
that is the success: function - and in that you do nothing with the returned 
results. I should also point out that *all* output from the script will be 
returned there. That means anything from an echo or var_dump statement, but 
also anything *outside* <?php and ?>, which means all the html that is in your 
file jq_test.php too. It's all concatenated together as one humungous text 
string and returned to your ajax success: function. And because you're not 
looking at those results, you won't see them.

>> 3) Where *are* you expecting the output from var_dump($_POST); to
>> appear, and why?

> As I understand, $.post [which is an Ajax call??] should put the results into 
> $_POST in the URL: in the call.

Well, it might put it into $_POST["move_from"], possibly, but I don't know what 
the JavaScript behind this jquery call actually does.

>> 5) For a simple but effective ajax example, see
>> http://www.clothears.org.uk.

> Looks good.

Thanks but have you understood it?

>> 6) If you're attaching an onclick to each table cell, the onclick
>> handler can write the cell's id into the form, seems to me. Why use
>> ajax for that?

> Please tell me how to do that [write cell's id into form].

Something like (e.g.):

Move From: <input type="text" name="move_from" id="xyz"></input>

and then in your onclick handler:

document.getElementById("xyz").textContent = this.id;

I'd say also that you need to keep separate your HTML page (where you display 
your 8x8 grid and click on the cells) from any PHP scripts you want to run with 
ajax.


--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to