Jump to content

phpknight

Members
  • Posts

    502
  • Joined

  • Last visited

    Never

Everything posted by phpknight

  1. Okay, I've never actually posted code, so hopefully I did this right. Bolding inside there wasn't working, so I have marked the two important lines with ************** above and below. // creates an XMLHttpRequest instance function createXmlHttpRequestObject() { // will store the reference to the XMLHttpRequest object var xmlHttp; // this should work for all browsers except IE6 and older try { // try to create XMLHttpRequest object xmlHttp = new XMLHttpRequest(); } catch(e) { // assume IE6 or older var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"); // try every prog id until one works for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) { try { // try to create XMLHttpRequest object xmlHttp = new ActiveXObject(XmlHttpVersions[i]); } catch (e) {} } } // return the created object or display an error message if (!xmlHttp) alert("Error creating the XMLHttpRequest object."); else return xmlHttp; } // read a file from the server function handleEvent(x, y, a, b) { **************************** var xmlHttp = createXmlHttpRequestObject(); normally this line is outside all functions ***************************** if (xmlHttp && xmlHttp.readyState!=1 && xmlHttp.readyState !=2 && xmlHttp.readyState!=3) { // try to connect to the server try { // get the two values entered by the user //FORMAT REQUEST HERE xmlHttp.open("GET", "THE URL" + params, true); xmlHttp.onreadystatechange = function () {handleRequestStateChange(x, y);}; xmlHttp.send(null); break; } } // display the error in case of failure catch (e) { alert("Can't connect to server:\n"+xmlHttp.readyState + e.toString()); } } else { alert ("Hold on a minute. I'm not finished!"+xmlHttp.readyState); } } function handleRequestStateChange(x, y) { switch (ajaxID) { case 1: // when readyState is 4, we are ready to read the server response **************************** //as soon as xmlHttp is referred to, the program halts because it does not recognize it since it is now inside the function if (xmlHttp.readyState == 4) ... *************************** }
  2. Nevermind. A man page does not explain the pros and cons of using a certain PHP wrapper, etc.
  3. xmlHttp is undefined It is saying that right away in the handleRequestStateChange function.
  4. Can you give me some example code there? I tried implementing this, and the statechange function does not see/recognize the Ajax object. I might be missing something.
  5. I think that might be right. In my current script, it has this before any functions: var xmlHttp = createXmlHttpRequestObject(); //this function does what you suggest So, if what you are saying is correct, then all I really have to do is somehow create the object inside a function, and then I will be able to use all the objects I want? But how will the server response, state change function, and processing functions not cancel each other out or otherwise mess up? Right now, if two different Ajax calls go out, one cancels the other. So, I just don't do anything until the first one finishes, but I know this defeats the purpose of using Ajax. Right now, in order to keep things separate, I send Ajax IDs with each call. So, a drag and drop might send 1 whereas a click on a list element would send 2, etc. That way, I use a switch to process it and process the server response correctly. This helps me use it but does not help with mutliple calls at once. Is this the right idea, or am I going about this part wrong?
  6. Right. And what I am saying is that imageMagick does not seem to have a good way to learn the basics. Even the books published on it are full of coding errors--just read the reviews. I cannot even find a discussion of which PHP interface to use, etc. So, if you have a lot of experience with imageMagick, let me know what you would suggest. If you are just talking about theory and do not actually use the program with PHP, then you are not helping solve the problem. Therefore, I will not be replying to irrelevant posts after this one.
  7. I tried scriptaculous, and their examples did not work. I've never used jQuery. I primarily use PHP/mySQL. For AJAX, I learned most from this book: http://www.amazon.com/AJAX-PHP-Building-Responsive-Applications/dp/1904811825/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1231542429&sr=8-1. But it only has one object that use used for the whole JS script. The examples I found online only discuss two objects, and that just delays but doesn't solve the potential problems. However, if it is so easy, if you could just point me in the right direction, I would appreciate it.
  8. Oh, okay. Corbin, every topic is potentially for newbies. You have to start somewhere, lol.
  9. If there were a section for imageMagick on here like for PHP, AJAX, and so forth that would be a good start. I'm basically at the point where I believe I've exhausted PHP's native image functions. For instance, I need to arc fonts but with anti-aliasing, etc., more like stuff you get in Photoshop. Even by modifying images at the pixel level, I cannot get close to what I need through PHP alone.
  10. I've found that the message boards on this topic are extremely poor for newbies. I'd really like to use imageMagick, but I cannot even get a straight answer on whether to use IMagick, MagickWand, or now phMagick. Also, all the books on the topic seem to get poor reviews.
  11. Hi, I am finally getting used to writing AJAX in combination with PHP, but most of the sample scripts dealing with multiple requests simply use two objects. What I am looking for is to use a multi-purpose AJAX script that I could use with a potentially infinite number of objects since most of my scripts rely heavily on databases. If anybody can point me on the way, that would be great. BTW, I don't want to use a library since I have been unable to even get one of the libraries to have all their test scripts even work on both IE and Firefox. Even the best ones seem to break. That being said, I'm open to suggestions
  12. Hi all, I just resolved an issue that seems unique to Safari and thought I would post it on this PHP board. The symptoms seem like a PHP header issue, but it really isn't. Hopefully it will save somebody trouble. If you use cookies, make sure you have the URL exactly the same everywhere. I had something like www.mysite.com in the insecure and www.MySite.com on the secure. It works fine in all the other browers, but Safari was seeing these as two different sites, and therefore it was causing issues with the cart. Luckily, somebody called me that was having a problem, or I might not have ever known. I usually only test in IE and Firefox.
  13. You can probably see the pages on Amazon or google books. Or, go to a local bookstore. One of those places like borders is bound to have a copy.
  14. Something is messed up. I've never had a time where it says I redeclared something I haven't. Sometimes it takes a few hours, but I always find it. Do you have a double include somehow? Try require_once everywhere and see if that fixes it.
  15. Is there a reason that you are defining that function right inside your code? If you just put it outside all that, it should be fine.
  16. You can a combination of split and/or strtok to get this done. For instance, to get the date, split it by a space, and then the 1st, 2nd, 3rd, and 5th indices. You skip 0 because that will be the day, skip 4 for the time zone. To get the 1 minute load, just do a split on "average: " followed by a split with a comma. Then take the zero index. That should get you somewhere. If you get stuck, you var_dump to see what is actually happening.
  17. What are you expecting as what does it give? I would do a var_dump on split to make sure that is what you think it should be.
  18. That book I recommended has mini-tutorials for every PEAR class in the book. So if you are going to be doing any real amount of coding, you should just pick it up. Seriously, I was able to do things with PEAR in days that would have taken months to figure out without it.
  19. Right, that is what I want. The problem was when I was using the example from the book, it sent xml headers. So, when I tried to get the responseText property, it was giving me the code with all the tags written out as special characters, so then the actual source code showed up on the page--like <div>...</div> instead of a box. I'm not sure why it was converting all the characters, though.
  20. I figured it out. Using the generated source is what I should have been looking at.
  21. Here is the solution I have found. Somebody please let me know if I should be doing something else. The books I have do not cover any responses except xml. Instead of xml, I sent this as the header: header('Content-Type: text/html'); Then, it works great. Is there any reason I might not want to do it this way?
  22. Hi, I have figured out that AJAX can send the response back as XML or just text. I was having some issues until I realized that it would be easier to get the responseText and put it in the DIV. Unfortunately, it appears that the responseText is not exactly what I send back, rather it is what I send with everything encoded for HTML special characters! So, the source code just appears right on the page instead of what I want. How do I get around this?
  23. It appears that the response send back from PHP is getting modified in many ways by the time it gets back to javascript. I've tried htmlentities, and many other things, but it always get changed--even the order of my attributes within HTML tags. I'll keep plugging along to see what I can find.
  24. UPDATE: The source is correct, but the generated source in the firefox toolbar is incorrect. Firefox seems to haphazardly modify the code in a very odd way--sometimes it changes characters to special coded equivalents, and sometimes chunks are just gone. I'll do some testing and see what response is really going back from php. In the meantime, if anybody has experienced these issues, please post.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.