|
Posted by Randy Webb on 01/19/06 12:10
one man army said the following on 1/19/2006 3:43 AM:
> In article <yIidnQ4mD5AopVLeRVn-rw@comcast.com>,
> Randy Webb <HikksNotAtHome@aol.com> wrote:
>
>>> * I have a very simple HTML page, with a FORM, with an INPUT TEXT
>>> * there is a button that activates some javascript
>>> * the javascript causes this to happen
>>>
>>> // Create new JS element
>>> var jsel = document.createElement('SCRIPT');
>>> jsel.type = 'text/javascript';
>>> jsel.src = url;
>> jsel.src = url + '?' + document.getElementById('zipRaw_id').value;
>>
>> And then have PHP read the queryString.
>>> document.body.appendChild (jsel);
>>>
>
> since the SCRIPT element is being appended to the current pae, I am not
> sure that the PHP would see a new URL.
It will. Test it.
> The URL is just the same URL as it was before the document.body.appendChild().
The URL to the current page may be, but the URL that is in the script
element is not. It will create an element and append it that looks
something like this:
<script type="text/javascript"
src="URLToFileOnServer.PHP?zipRaw_id.value></script>
> The point here is that things chane on the page without jumpin to a
> new location, ie AJAX. I do not want to refresh the window.
There is no need to. But if you are getting data from the server by
creating Script Elements, you are using the wrong term for it. It is not
AJAX but rather it is Dynamically Loading Script Files. Search the
comp.lang.javascript archives for those words and my name, you will find
some interesting reading.
> I could look up the PHP built in variables that read the URL, but I
> think thats not the right direction.
It is the right direction, if what I have read so far is what you are
trying to do.
> --
>
>> So your browser's JavaScript interpreter attempts to run the output from
>> the PHP.
>>
>> Bit of a mess.
>
> Yes, it seems Javascript would execute the output of the PHP, but you
> don't use it that way. The point is to execute PHP as the result of a
> page event, which it does.
And when you append that Script element to the page, and the server
returns information from the request, then the browser will attempt to
execute that data as script content.
> After the PHP executes, you get access to the set PHP vars from
> Javascript. e.g,
>
> setTextContent( getElementById_s('divZipCheckRes'),
> '<?php echo $res; ?>' );
>
> I just wish that I could access SOMETHING in the web page from within
> the PHP to get an input value. I don't know how to do that.
I told you how.
Since I do not find the Original Message of this thread in
comp.lang.javascript it would help a lot if you posted to clj what you
are trying to do. It appears you are trying to do something like this:
Take the value of an input element.
Pass it to the server.
Have the server process some data based on that input value.
Return some data to the browser.
Have the browser process that data.
All without reloading the page.
And that is precisely what I told you how to do :)
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Navigation:
[Reply to this message]
|