Advanced XMLHttpRequest Usage
Please understand that I know how to code in both javascript and PHP and know how to use AJAX very well. I have an entire scheduling system set up with employee management and shift requests using the XMLHTTPRequest object.
That said, here is my question/dilemma:
Within said scheduling system, I have a span that is filled using the xmlhttprequest object. That span, once filled, is able to call javascript functions from the parent document (i.e. the page that is loaded into the span can call functions in the page that contains the span). However, if I would like to be able to access objects within the AJAX loaded span. Is there a way to do this?
A specific basic example:
page1.php contains a span with id="test_span"
page2.php contains a table, with a cell that has an id='cell1'
page2.php is loaded into test_span using AJAX
page1 calls a javascript function that uses "document.getElementById('cell1') and changes its color...nothing happens (no javascript errors either)
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Advanced Filesystem Usage (Warning: SAFE MODE Restriction In Effect.)
I'm working on the automatic News insertion functionality, which is simple enough in itself. But where I'm having the problem is dealing with uploading image files. Since we use screenshots from in game as pictures to give viewers a more interesting view of what the news article is about, I need to be able to store images for the news files on the server. Now, I could store all the images in one images folder, but I wanted to do something different. Which, with the form that I created to allows uploading of images, it will store them in a subdirectory of the images/ folder that is similar to the current date they were uploaded on. ie today would go into "images/04.15.03/file.gif" basically. I'm authenticating the uploaded file fine from what I can tell. The hard part first came in getting the subdirectories to be created with the mkdir() command. At first it just wouldn't do it, after trying several ways. Finally I figured out I had to change the priveleges of the directory on the server. After that I was able to create subdirectories in PHP. Problem is, I'm using move_uploaded_file() which is considered safer and works better in safe mode. But I'm recieving the following error. Warning: SAFE MODE Restriction in effect. The script whose uid is 547 is not allowed to access /%mybasedir_hiddenfrom you%/images/04.15.03 owned by uid 48 in /%mybasedir_hiddenfrom you%/classes/class.files.php on line 225 The line it points to is the move_uploaded_file() function. From what I've heard through safe mode you can't upload to dir's you create or something due to the owner of them. But I already set the created dir to full priveleges. I'm wondering if there is a way to sort of log into the apache server via php and create the directly as the site owner that way. Here are the code snippets: PHP Code:
View Replies !
View Related
Xmlhttprequest
I tried the AJAX example that was posted in the Article section and it works fine. Now I am try to incorporate this into a project, but I am fighting with checking if my code has received the PHP Result. I try to query the .readyState but the only think happen is that I am looking up the script (Doesn't matter I am using do/while or while). Is there another trigger that need to happen to update .readyState or is there another variable that can be checked?
View Replies !
View Related
Developing With DOM And XMLHttpRequest
I have to write a web program (not a web site) and I was exploring all possibilities. When I found XMLHttpRequest I decided to use it. I'm interesting also in DOM, and I formuled this idea of a PHP framework: for every page of the program: - an XML file where there are all the static parts, and where the dynamic part have to go (after a DB query, etc.) you put something like <div id="where_the_table_have_to_go"></div> - a .php file that initialize the dynamic data of the page, created with DOM objects and with something like that (I don't know the correct syntax, it's only an idea): $doc = new DOMDocument("file.xml"); // DB query and $table creation with DOMElement and so on... // and finally $panel = $doc->getElementsByTag("where_the_table_have_to_go"); $t = $panel->createTextNode($table.saveHTML()); // I don't know if TextNode is correct :) $panel->appendChild($t); - a .php file with the right Javascript code to use XMLHttpRequest. When in the browser a change occours, the JS function call this file to upgrade the desired node of the page. Finally he answers with something like: creatTextNode($table.saveHTML()); Is all that possible? Anyone knows if there are some libraries that uses DOM and XMLHttpRequest together? Is it possible to update only a node of a page with XMLHttpRequest?
View Replies !
View Related
Suggestions For Using XmlHTTPRequest
So I've started using the uber cool xmlHTTPRequest on one of my forms to populate a select field. It works really well and I'm surprised how seamless it all is... I do need some suggestions on use. Here's my situation: I have a Country select field that is populated by a mysql request - the options here are loaded and one of them is selected based on the users' default value. Based on this value (country) the State select field populates itself with the states for that respective country and even select the default state for the user. This select field is populated by my xmlhttprequest friend. I have this all working. However, I currently have to have the user click on the EMPTY State select field in order to load the states... looks kinda lame. I use the "onChange" function to call my loadXMLDoc() method... which in turn pulls the states based on the selected Country value. Here's my problem: In order to populate the state field, I need an event handler to initiate the loadXMLdoc() function ... ala "onChange", "onClick", etc. If I DONT auto-select the country field and let the user do it, I can use onChange and load the states for that particular country. This works for the New Profile form, but it doesn't work for the Edit Profile form which should auto-select everything and show the user his previously selected values. So my question is, what's the best approach to have the states load when the form is loaded? Based on what country is automatically selected... ? I have thought of using onLoad() for the BODY tag, but since it the BODY comes from a global include, I don't want to clutter it with functions I don't really need for a lot of pages. Is there any way to access this data without going through "onchange" or the like? Is there a better way to do what I want?
View Replies !
View Related
XMLHttpRequest Not Posting Data To Php
i have the following javascript code: --------- try{F=new ActiveXObject("Msxml2.XMLHTTP")} catch(e) { try{F=new ActiveXObject("Microsoft.XMLHTTP")} catch(e){F=typeof "XMLHttpRequest"!="undefined"?new XMLHttpRequest():0} } if(F) { F.open("POST","http://www.myurl.com/php_page") F.onreadystatechange=function(){F.readyState==4?ev al(F.responseText):0} F.setRequestHeader("Content-Type","application/x-www-form-urlencoded") F.send("foo=bar&stuff=test") } -------- when i run this in firefox 1.5 the "post" fields are recognised by php, however, when i use internet explorer 6.0 the "post" fields are not recognised by php. i have checked the headers sent in IE and they appear to be correct (eg, Content-Type = application/x-www-form-urlencoded"...). as suggested in another post, i have enabled the "always_populate_raw_post_data" directive in my php.ini file, yet the "post" fields still don't exist.. also, when running phpinfo() on the page that is being posted to, $_SERVER["REQUEST_METHOD"] = "GET" - something is wrong here. is it something to do with the the script above, the browser or the server?
View Replies !
View Related
Post A Form Using The XmlHttpRequest Object
I'm trying to post a form (using POST not GET) using the xmlHttpRequest object. I cannot work out how to get PHP (4.1.2) to read the data which I'm submitting. Everything works fine if I use GET I can just read it from $_GET. If I use POST nothing appears in $_POST. To try to use the POST method I'm encoding the fields into a URL encoded string and sending it as the parameter to the request.send() function from Javascript. /Something/ is going out because I can see it in the LiveHHTPHeaders extension to Firefox. Presumably it's being received by the server. But how on earth do I get at it!?
View Replies !
View Related
Toggle Display Option That Use An XMLHttpRequest To A Query.
I have been trying to resolve this issue for a few days now but I just cant get it. The following works intermittent. I have a toggle display option on one of my pages that use an XMLHttpRequest to a PHP query. I have already read the article on PHPBuilder and a few other places but I cannot find anything that would help me. Here is the index.php section that calls the XMLHttpRequest. function ToggleDisplay(FactID) { Cell = "dis"+FactID; var obj = (document.getElementById) ? document.getElementById(Cell):(document.all)?document.all[Cell]:null; if (obj) { if (obj.innerText == "Display: Yes") { obj.innerText = "Display: No"; sendString = 'dynamicUpdate.php?Action=ToggleDisplay&Other=False&FactID='+FactID; } else { obj.innerText = "Display: Yes"; sendString = 'dynamicUpdate.php?Action=ToggleDisplay&Other=True&FactID='+FactID; } } req = new ActiveXObject('Microsoft.XMLHTTP'); req.open('get', sendString); req.send(null); } I am only allowing users to use IE5+ and that is why I only create a new instance of ActiveXObject('Microsoft.XMLHTTP');. Here is the dynamicUpdate.php (simple., easy, and affective): <?php $query = "UPDATE facts SET Display = ".$_GET['Other']." WHERE FactID = ".$_GET['FactID']; $conn = odbc_connect('****', '****', '****'); odbc_exec($conn, $query); odbc_close($conn); ?>
View Replies !
View Related
Self And $this Usage
Is it possible to do without $this? I have got an instance of another class inside a class. Now I want to access this classes functions using the self keyword, but it seems i cant. Or can I? Like, self::$nexgen->Function? Or do I have to use the $this keyword. Having both keywords seems pointless to me, i'd like to stick with one... Maybe im getting confused.
View Replies !
View Related
PHP Usage Eg XML
I am just a beginner at php, and I know that it is used for dynamic content in web pages, but I was would like to know if it can be used very easily to create dynamic documents instead of web pages. eg openoffice XML documents. What I would like to do is basically have a database driven document template with headers, footers, page layout etc. and put formatted content in it. I think html is a bit limited for my application, but I may be wrong.
View Replies !
View Related
PHP Usage
PHP usage peaked. see http://www.php.net/usage.php I'm wondering what the reason for this is. Several possibilities are: Mindshare moving towards Rails/Python Frameworks Growing number of "PHP Sucks" posts Inability of PHP to be respected in the enterprise
View Replies !
View Related
RAM Usage
i just found this by brett about the mods to this board from june 2002," Removed "template" page generation in favor of inline on-the-fly generation. This reduced amount of memory used per page view by up to 2 megabytes. Not all that important at 10k views a day, but at 100k views, it's critical. "
View Replies !
View Related
OOP And RAM Usage
How is it with RAM usage by classes and objects? I found out that PHP4 uses more RAM than needed (read: make too more copies of data) - perhaps while calling functions or creating class. How is it in PHP5? Are all functions of class copied in the RAM for every created object?
View Replies !
View Related
Advanced Regex Help
having a few problems with a script im developing for www.cockneyizer.com the script translates websites into cockney rhyming slang, ive got the translation bit working but grabbing images of the server isnt flawless, in addition, sometimes links dont get converted to link back to the cockneyizer translation url heres the code, if you have any ideas of how to make it work better please <?PHP // remove cockneyizer translate url from $file $file = str_replace("http://www.cockneyizer.com/translate/.php?file=", "", $file); if (!eregi("http://", $file)) { echo "Please enter a valid URL (missing http://)"; } else { $fp = @fopen("$file","r"); if (!$fp) { echo "Core Blimey, no such page mate"; } else { $input = implode("", file($file)); include('dictionary.inc.php'); while(list($text,$image) = each($replace)){ $input = str_replace(strtolower($text), strtolower($image), strtolower($input)); } $input = preg_replace("/name=movie value=(["'])(([a-zA-Z0-9/.-\_^'^"])+)(["'])/", "name=movie value=1$file/24", $input); //flash $input = preg_replace("/src=(["'])(([a-zA-Z0-9/.-\_^'^"])+)(["'])/", "src=1$file/24", $input); //images $input = str_replace("'//", "'/", $input); $input = preg_replace("/background=(["'])(([a-zA-Z0-9/.-\_^'^"])+)(["'])/", "background=1$file/24", $input); // background images $input = str_replace("'//", "'/", $input); $input = preg_replace("/([^w/])(www.[a-z0-9-]+.[a-z0-9-]+)/i","$1http://$2", $input); //make sure there is an http:// on all URLs $input = preg_replace("/href=(["'])([w]+://[w-?&;#~=./@]+[w/])/i","href=" http://www.cockneyizer.com/translate.php?file=2", $input); //make all URLs links $input = str_replace("'//", "'/", $input); echo $input; } } ?>
View Replies !
View Related
Advanced PHP Debugger
We 've installed ADP. But I have a problem. All generated trace file are empty (only 1 byte). Any idea what the reason could be ? Right/Permission issue ? I'm not sure cause the file is created without any problems.
View Replies !
View Related
Advanced PHP Graphs
I have to create graphs which you can zoom into and have more controls. I dont want to use a Java Applet and would love to use PHp and any of its library. I guess such thing can be done with PHP and Flash and/or Javascript etc. Please guide me. A point to a tutorial or an example will be highly appreciated.
View Replies !
View Related
Advanced Php Counter
I am looking for a advanced php counter. I mean not to increase when I hit 'Refresh' button of the browser and NOT to use SQL database. All the PHP counters I found on the web use a text file that is modified (open, and increase value of the content) when the 'index.htm' is requested by browser (and of course if I request twice from the same browser, same machine it will increase).
View Replies !
View Related
Advanced OO Topic
I notice a strange behavior in PHP4 and wonder if anyone can explain it. Essentially, when I extend a class from a built-in module, I can add and access variables but can not access new functions I create within the extended class. This has only happened attempting to extend classes from ming, but I suspect it may be a universal problem (?). That is: <?PHP class foo { } class bar extends foo { function bar() { print "bar"; } } $bar = new bar(); $bar->bar(); //PRINTS "bar" ?> Works as expected, however, in: <?PHP class foo extends SWFSprite { var $x = 10; function bar() { print "bar"; } } ?> running: <?PHP $foo = new foo(); print $foo->x; //WORKS; PRINTS "10" $foo->bar(); //RETURNS "Undefined Function" FATAL ERROR ?> Can anyone explain this behavior? Will it be fixed in PHP5? Is it related to the Zend engine? Any workarounds?
View Replies !
View Related
Advanced PHP Pagination
Is there anyone who could help me create an advanced pagination code? The basic: 1. Data to paginate will be coming from msyql database. 2. 10 or 20 items per page. etc, etc... The problem: Limit the number of page numbers to 5 when pages reach more than 5 pages. Example: Total pages: 10 sample page listing output: start of pagination 1.) << 1 2 3 4 5 >> displayed when last page number is clicked (5) on start of pagination 2.) << 3 4 5 6 7 >>
View Replies !
View Related
Advanced Search
Im looking to do one of the more advanced searches where you have a form you can narrow the search by username, user type, date entered, etc. Everywhere I've looked all I can find is the basic searches. Can someone point me in the right direction or show me some code.
View Replies !
View Related
Advanced Form
I don't know how it's called, but I want to ask how to make a form which able us to make bold, quote, link or change font color by using [].. like in this forum.
View Replies !
View Related
Advanced SQL Query
I have built a script that checks if another server is up or down. If the server is down it stores the timestamp in a MySQL database – but if the server is running nothing is stored. The reason why I don’t store the uptime is because the scripts runs every minute, so the database would fill up really fast so Iamm trying to avoid string the uptime. The problem is when I want to select the last downtime I want to count how many minutes the server was down. The database looks something like this: Id – Date 01 - 2005-11-17 12:00:00 02 - 2005-11-17 12:01:00 03 - 2005-11-17 12:02:00 04 - 2005-11-17 12:03:00 05 - 2005-11-17 15:00:00 06 - 2005-11-17 15:01:00 07 - 2005-11-17 15:02:00 08 - 2005-11-17 15:03:00 Okay, according to the table the last downtime was November 11 @ 15:03 and then the server was down for 4 minutes.
View Replies !
View Related
Advanced Captchas
I know there are tutorials for making really simple captchas, but I think that most spambots today can probally crack them easily. How can I make an advanced one like the ones rapidshare uses?
View Replies !
View Related
Advanced 'include'
See, I read somewhere about only having one template file so layout design is easy to change, which I loved the idea. But right away I thought I might have a problem somewhere, so I tried it out, and of course, I did. What I'm doing is (mind you these tables and pages are just for testing): I have a php file that lists all the songs i have in a table and links each song title to $PHP_SELF?id={$row['id']} which displays different information which works just fine by its self. Code:
View Replies !
View Related
Advanced Order
Using PHP loops I have a screen print something like this: 1) Owners [1 1) Management [1 2)Manager [1 2)Supervisor [2 1) Programming [1 The table has a column called `tier` which corresponds to the #)'s, which are updated via the loop. Another column is `the_order` which is updated via select fields and it corresponds to the [#'s. Does anyone know some way using group by or something of that nature with to have a select field print out the results in that order. PHP Code: $query = "Query in question"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { echo "<option value="$row[id]">$row[name]</td>"; }
View Replies !
View Related
Advanced Graphing
I have a big fat database table full of records that include a date, a time and a value. The records look something like this: 7/7/2006 11:05 200 7/7/2006 11:10 300 7/8/2006 11:05 100 7/8/2006 11:10 50 How can I query this data and have it arranged as so: Code:
View Replies !
View Related
Advanced Arrays
i have been mucking around with my foreach loop for a while, but i need a way to generate tables, with php, just a table that i can put values into but depending on haow many values - $files - i need a square table Code:
View Replies !
View Related
GD And FreeType Usage
I've got everything installed finally and am seeking a little help getting started with the PHP. I need to take an existing jpg image and write some text on it using a true type font I specify. Does anybody have or know of some sample code I can take a look at?
View Replies !
View Related
Mysql_pconnect Usage
Can I use mysql_pconnect on an environment like this? There is just 1 server on which both PHP and MYSQL runs. It is an intranet server. At any point atleast 2 people will be actively using the server for their work. If the script uses mysql_pconnect and then the normal user name and password, will this speed up execution of scripts on the server by any chance?
View Replies !
View Related
Memory Usage & Php
today i have written a script (using the safox api) to convert data from a mysql database to several xml files. we re talking about quiet alot of data. When i run the script it goes incredibly fast, it creates like 650 xml files in 20 seconds (while with my earlier script not using sofax it took like 20 minutes for the same amount of data). anywayz, i got a new problem now after it ran 1 minute and processed about 1200 xml files, i get the next error: Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 52 bytes) in C:wwwxmlswitchclassessafox_g.cls.php on line 767 i know what it means, and i know that i could solve the problem with messing around with ini_set or just change the max memory size in php.ini, but that is what to avoid doing. do you guys got any tips on saving memory usage while using php? is there something like .net's "garbage collection" in php? or is there any other way to save memory ?
View Replies !
View Related
High CPU Usage?
I've got a windows server, running PHP 4.4.2. It hosts a few different sites, and one of them is causing high cpu usage spikes (70% utilization). Because these aren't constant, it's hard to find a way to measure them. It's not all my code, so I don't really want to go modifying it to track down the high usage. Nor do I want to be taking sites down to determine where it came from (I will if I have to though) Is there a way to determine which php script is causing this cpu usage?
View Replies !
View Related
Restricting Usage
I am creating a script that allows users to create an email account at mydomain. (Cpanel) I would like to restrict usage of the script to prevent misuse. How could I do error checking to ensure that the script is only used once within a 5 minute timeframe? Or am I going about this the wrong way?
View Replies !
View Related
CPU Usage & Scripts
I was hearing horror stories about people whose BlueHost accounts were suspended for 'CPU Overuse'. I contacted BH (because I was considering moving there) about this and they said the biggest killer of CPU was "SELECT * FROM". As somewhat of a noob to PHP, I don't know of any other way to get a whole row of data other than this: "SELECT * FROM table WHERE colname = variable LIMIT 1" Is there something I'm missing on optimizing my code?
View Replies !
View Related
Advanced Mysql Query
There are currently two queries in one of my scripts. One is: SELECT * FROM foo the other is: SELECT var FROM bar WHERE something = 'somethingelse' Is is possible to use a join statement and combine these two into one query? My reason is that I'm trying to speed up the script, and hopefully combining the queries will do that.
View Replies !
View Related
Email Validation (advanced)
so i know this can be done and i'm pretty sure PHP can do it, i'm just not sure if i need to set up a cron or something. I need a way to be able to send out emails when someone subscribes to a service (this i know how to do) and then when they recieve the email they need to respond to it, then when i recieve their response, their membership is confirmed.
View Replies !
View Related
Upgrading Php On WIN 2000 Advanced
I am currently using php 4.04 on a WIN 2000 advanced server and I want to upgrade. I downloaded the win32 4.3 installer and think its just a matter of running the installer to complete the process. Is there anything else I need to configure (besides the php.ini) to keep my existing scripts running correctly? I am running multiple sites on one domain so I don't want to screw up the upgrade and cause any downtime.
View Replies !
View Related
Advanced Search Replace
im developing a script which grabs remote html files and shows them on the local server, ive written some code which changes the path of image files to point to the files on the remote server, this code can be seen below: Code:
View Replies !
View Related
Advanced Dropdown Menu
I want to populate a dropdown menu with countries that are in one column of my table. I know how to do that, but I can't find how to eliminate multiple items. Some countries appear several times in different rows, but I only want each available country to be shown once in my dropdown list.
View Replies !
View Related
Advanced Email Validation
I need a script which checks if an email address exists. I've been testing a few scripts, but all of them only validates the domain, for example, the script says this email exists; foo_this_email_does_not_exist_123456789@hotmail.com Just because the domain exists. For example, Is it possible to check if the foo_this_email_does_not_exist_123456789 account exists on Hotmail's server? Or foo_account at usa.net's server?
View Replies !
View Related
Advanced Registration Forms
I'm trying to design a registration form so that when the user fills the form fields if he made a mistake i.e (forgot to fill the last name field) and then returned back to the form page he finds all the fields he has filled existing only the one with the mistake highlighted. So is there a way to design such a form using php?
View Replies !
View Related
Advanced Form Jiggerypokery?
Can any of you mySQL/PHP masters help me? What I wish to do is have a piece of text saying 'You have already filled out this form' when a user has previously filled out a form and submitted it. Our site (http://www.pickawin.net) uses quite a few forms and users have requested the functionality to be notified if they have already filled out a certain form on the site.. It is a PHP-fusion installation, using a mySQL DB. I understand it would require (something like) the form, once filled out and submitted, to create an entry against the user's name in the mySQL DB and the an entry for the form they have just filled out - then when the user goes back to the page, for a bit of script to be called to show whether they have prevously filled out this form or not.
View Replies !
View Related
Advanced & OO PHP Book Recommendations
I can create fully functional websites, custom CMSs and so on. However, I would like my code to be more modular, easier to maintain, and generally "better." I'm not very good with object-oriented PHP at all, and I would like a book that can get me on that path, as I think it's the way to go, (correct me if I'm wrong), and generally get me thinking about advanced and/or different PHP techniques. I've read that Larry Ullman is a good author. Is this true for what I am looking for, or are his books more like "LAMP for Dummies" -type books? I've always just used the PHP manual to figure things out, but I want to advance my coding. I'm not looking for a reference manual of functions and stuff - I'm looking for techniques and ideas.
View Replies !
View Related
|