I'm not sure what you're trying to do makes sense.
You'd have to write some PHP code to receive the AJAX request and use it
to update the variable. There's nothing in PHP that will do this
automatically.
However, since, I believe, PHP variables are usually only 'in scope' for
the context of the request, I'm not sure _what_ variable you are trying
to update. I suppose you could update a session variable, and that
might make sense. But it doens't sound like that's what you're trying
to do.... it sounds like what you're trying to do is something
fundamentally impossible.
But if you have a PHP script with "$searchterm = 'drawing';" in it, then
that statement gets executed (setting $searchterm to 'drawing') every
time the PHP script gets executed. Which is every time a request is
received that executes that PHP script. It doesn't matter what some
_other_ request did, and an AJAX request is just some other request. You
can't use AJAX to change your source code. (Or, I suppose, there would
be SOME crazy way to do that, but you definitely definitely wouldn't
want to!).
On 12/5/2011 5:08 PM, Nate Hill wrote:
> If I have in my PHP script a variable...
>
> $searchterm = 'Drawing';
>
> And I want to update 'Drawing' to be 'Cooking' w/ a jQuery hover effect on
> the client side then I need to make an Ajax request, correct?
> What I can't figure out is what that is supposed to look like... something
> like...
>
> $.ajax({
> type: "POST",
> url: "myfile.php",
> data: "...not sure how to write what goes here to make it 'Cooking'..."
> });
>
> Any ideas?
>
>
|