Jump to content

techtheatre

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    KY - USA

techtheatre's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a script that needs to update a record in a database (standard UPDATE query). Unfortunately, this script is in a general function used by a variety of processes in my scripts, and occasionally there is no record to update, so i would need to use an INSERT query. Is there another type of query besides INSERT and UPDATE that will instead UPDATE if it exists, and if not, INSERT?... Currently i have to run an extra query just to see if it exists before i can run the actual query that i need to run...surely there is a better way...some sort of conditional insert/update... Thanks!
  2. Apparently "fenway" did not get the point of my question as he/she thought that this topic needed to be moved to the freelancing section. I AM NOT however looking to have someone write this script...i am sure that there are countless instances of it out there already open source because I see it in use frequently. I am only looking for guidance as to WHERE TO LOCATE such a script. I believe i said that pretty clearly in my original post when i said: Thanks for the "help" fenway, but next time let me post my question where it best belongs and not worry about you moving it in some completely unrelated category. This was originally posted in JavaScript. If someone reads this who has the ability to move it back, that would certainly be appreciated.
  3. Anyone know a way to autosave the data contained in a form using AJAX? Basically i have a form with LOTS of fields and it takes a long time to get them all filled out. I want to set up javascript to run a function every 5 minutes (for example) that silently submits the form. When the form is submitted all that happens is that the form data is all saved (in MySQL with UPDATE function), so if i could silently submit the form and just let the user continue working without knowing anything even happened, that would be ideal. Seems like this should be easy, but i can't find a way to submit the form content without redirecting the form to the submission page. Can this be done silently? Thanks! :-\
  4. I am looking for a JavaScript that will do something similar to the "top stories" slideshow found at Time.com I have located "Frontpage Slideshow" which is a commercial plugin for Joomla, however the site i am working on is not based in Joomla, so that does me no good. Could anyone point me in the right direction (even an appropriate Google search phrase, as i seem to be completely striking out). Thanks! The Key Points: 1. Needs to NOT use Flash. 2. Should show feedback about which article number/slide we are viewing (never more than 4 or 5) 3. Should link (when clicked) to a page URL not an enlarge image (as most slideshows do) 4. Must be cross-browser compatible and degrade nicely to a single link/image (probably just with "<noscript>" tag) THANKS!
  5. Okay...i have some new info (but still need help)... First of all, here is the line that is called in the popup that triggers the ajax reload in the main window and also closes the popup at the same time: onLoad="window.opener.ajaxFunction();self.close();return false;" Here is why that matters...it all works (still) in Internet Explorer 7. It still does not work in Firefox. I have discovered that the problem is that the popup closes before the ajax call function completes. If I remove the self.close() command from my popup window, the main window refreshes its content with no problem. Unfortunately, I need to have the popup close itself...so this is not a solution. Is there a way to tell the ajaxFunction() to execute and not care if the code that initially told it to execute sticks around? I know i could build in a delay on the self.close() but that is not really the solution i am looking for either. Hopefully someone knows what i can do to solve this for Firefox. THANKS! :-\
  6. well...all you need to do is google "AJAX Tutorial" to uncover hundreds of basic scripts to handle an ajax call...here is one that i have used in teh past: <script language=\"javascript\" type=\"text/javascript\"> <!-- //Browser Support Code function ajaxFunction() { var ajaxRequest; // The variable that makes Ajax possible! try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try { ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\"); } catch (e) { try { ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\"); } catch (e) { // Something went wrong alert(\"Your browser broke!\"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { // the next line inserts retrieved data into a DIV area called <AjaxContentDiv>...change this to whatever the ID of your DIV is document.getElementById('AjaxContentDiv').innerHTML=ajaxRequest.responseText; } } var lookupRequest = 'page/to/call/here.php'; ajaxRequest.open(\"GET\", lookupRequest, true); ajaxRequest.send(null); } //--> </script> There are two parts of this code to modify: 1. the name of your <div> (in this case, change "AjaxContentDiv" to "hits") 2. the URL of the script that returns your value ( var lookupRequest = 'page/to/call/here.php'; ) Other thoughts: I still think that even with 2000 visitors each day (which you may want to check out Google Analytics because you probably have a skewed view of your "real" traffic if you are managing a website with that much traffic but don't know the basics of modern web development), you are going to ruin the good benefits of ajax by requesting updates every 5 seconds...this is not what ajax was developed for and will product tremendous server and client overhead. On top of that, if you do the math... 2000 per day / 24 hours = 83 per hour 83 per hour / 60 minutes = 1.3 hits per minute This would indicate that refreshing the hit count once per minute should be sufficient...or at the most once every 45 seconds. Obviously you can (and will) do whatever you want, and the tools are available to do it...but i think that your plan should be at least somewhat re-considered.
  7. give this a shot...(NOTE: I did not create this code, it was given to me in response to a similar post that i made on another forum at: http://www.webmasterworld.com/css/3337813.htm) <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>test page</title> <script type="text/javascript" language="JavaScript"> <!-- Copyright 2006 Bontrager Connection, LLC var cX = 0; var cY = 0; function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;} function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;} if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; } else { document.onmousemove = UpdateCursorPosition; } function AssignPosition(d) { d.style.left = (cX+10) + "px"; d.style.top = (cY+10) + "px"; } function HideContent(d) { if(d.length < 1) { return; } document.getElementById(d).style.display = "none"; } function ShowContent(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); dd.style.display = "block"; } function ReverseContentDisplay(d) { if(d.length < 1) { return; } var dd = document.getElementById(d); AssignPosition(dd); if(dd.style.display == "none") { dd.style.display = "block"; } else { dd.style.display = "none"; } } //--> </script> <style type="text/css"> div.FAQ { color: #336633; font-weight: bold; font-size: 12px; font-family: Arial, sans-serif; background-color: #ffffcc; text-align: center; padding: 10px; border: solid 1px; position: absolute; display: none } #UNIQUEID { background-color: #ffc; position: absolute; display: none } </style> </head> <body bgcolor="#ffffff"> <p> blah blah blah... </p> <p> blah blah blah... </p> <p> blah blah blah... </p> <p> blah blah blah... </p> <a onmouseover="ShowContent('UNIQUEID'); return true;" onmouseout="HideContent('UNIQUEID'); return true;" href="#" target="_self">LINK</a> <div id="UNIQUEID" class="FAQ">IMAGE OR TEXT HERE<br> </div> <p></p> </body> </html> hope this helps.
  8. several thoughts... one is that you should be careful wiht this...refreshing the content every 5 seconds is PROBABLY going to be a bit overkill unless you are really expecting LOTS of traffic on the website. This will simply lead to extra unnecessary overhead on your server and bandwidth. If you really do have hundreds of new hits every minute, maybe you should program a "fake" hit counter that starts wiht your current number and increments it locally on its own based on the average rates of new visitors to your site. It could check in with the server every couple minutes to adjust as needed in case the numbers are not jiving perfectly. two...the </div> tag needs to be closed INSIDE the body section...rather than outside it: ...<body><div>content in here</div></body>... three...your javascript should be placed outside the div, as you will be replacing the entire contents of the div four...you can set a timer in your javascript using: setTimeout(expression, msec); your 5-second example would be 5000 milliseconds (the second parameter) five...you will want to find a basic/generic ajax function (there are thousands of tutorials on implimenting ajax...just Google that) to call as the expression, and then replace this DIV's contents with the returned value from the AJAX request I hope this helps.
  9. Okay...I found line 106 (in firebug's line numbering)...an excerpt follows: (the line numbers are not in the original posting...but are left here for clarity) 102 ajaxRequest.onreadystatechange = function() 103 { 104 if(ajaxRequest.readyState == 4 || ajaxRequest.readystate == 'complete') 105 { 106 if (ajaxRequest.status == 200) 107 { 108 // SUCCESS 109 // the next line inserts retrieved data into a DIV area called <AjaxContentDiv> 110 document.getElementById('AjaxContentDiv').innerHTML=ajaxRequest.responseText; 111 } 112 else 113 { 114 // this might be a 404 if the page is missing (or other error number) 115 document.getElementById('AjaxContentDiv').innerHTML = '<strong><font color="red">ERROR: Unable to access source data.</font></strong>'; 116 // alert("ERROR: Page status is " + ajaxRequest.status); 117 // return false; 118 } 119 } 120 else 121 { 122 // readyState has changed but <> 4 123 document.getElementById('AjaxContentDiv').innerHTML = '<img src="images/ajax_loading.gif"> LOADING...'+ajaxRequest.readyState; 124 } 125 126 } So, now that this bit of info is cleared up...what does it all mean? My best guess (and remember i am a noob at this and really am just shooting in the dark) is that the ajaxRequest.status value is somehow not defined. This seems odd, since in order to get to that line of code at all, the ajaxRequest.readyState is supposed to equal 4 (or "complete"), which my screen output indicates is not happening...it stalls out at 2...but that may just be that it is skipping 3 and has not yet gotten to the line that would display the new output...it breaks too soon. Anyway, it seems that the need for a return value of 200 (which i added in because i read it online somewhere that it is necessary for error checking) is causing the problems. How do i ensure that a valid page response code is returned (or is this not even the problem)? Thanks!
  10. Well...unfortunately i am new to the firebug add-in (i have heard about it for a while, but never installed it). i have it now (and it is very cool)...but i don't know where to look for whatever i am looking for. I did get an error under the "console" tab when i made the request, so i assume that this has to do with the problem at hand...but the message doesn't begin to mean anything to me: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://xxxxx.xxxxx.com/admin/prod_opt_manage.php?ProdId=257 :: anonymous :: line 106" data: no] http://xxxxx.xxxxx.com/admin/prod_opt_manage.php?ProdId=257 Line 106 I looked at line 106 in my script, and in the outputted HTML...and there is nothing even related to this on either of those lines...??? Any idea what the above means or where to look for the problem? Why is it working fine in IE but Firefox is finding this error? THANKS!!
  11. i have re-posted the last part of this in the AJAX section of this forum. Here is the link: http://www.phpfreaks.com/forums/index.php/topic,157804.0.html I am also marking this as "solved"...though the question does continue at the other location. Thanks.
  12. I have a page that calls an ajax function "ajaxFunction();" with an onLoad call when the page first is opened. This populates part of the page with external data. Then the user may click an "edit" link that opens a popup window. Upon completion in that window, they click a link that closes the window and "refreshes" the ajax content (from the same URL as the initial page load): <a href="#" onclick="window.opener.ajaxFunction();self.close();return false;">close this window</a> This works fine in IE7, but Firefox starts the new ajax request but gets stuck at readystate == 2. For troubleshooting, I have a mouseover link on the "main" (window.opener) page that i can use to manually trigger my ajaxFunction() script, and that link successfully refreshes the content in Firefox, so the problem has something to do with calling it remotely and then closing out the window (i think). This is the link (in the main window) that works fine: <a href="#" onmouseover="ajaxFunction();">RELOAD (mouseover)</a> Here is my (very generic) AJAX scripting: <!-- AJAX BEGIN --> <script language=\"javascript\" type=\"text/javascript\"> <!-- //Browser Support Code function ajaxFunction() { var ajaxRequest; // The variable that makes Ajax possible! try { // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try { ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\"); } catch (e) { try { ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\"); } catch (e) { // Something went wrong alert(\"Your browser broke!\"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4 || ajaxRequest.readystate == 'complete') { if (ajaxRequest.status == 200) { // SUCCESS // the next line inserts retrieved data into a DIV area called <AjaxContentDiv> document.getElementById('AjaxContentDiv').innerHTML=ajaxRequest.responseText; } else { // this might be a 404 if the page is missing (or other error number) document.getElementById('AjaxContentDiv').innerHTML = '<strong><font color=\"red\">ERROR: Unable to access source data.</font></strong>'; } } else { // readyState has changed but <> 4 document.getElementById('AjaxContentDiv').innerHTML = '<img src=\"images/ajax_loading.gif\"> LOADING...'+ajaxRequest.readyState; } } var lookupRequest = 'ajax_display_options.php?OpdId=$OpdId'; ajaxRequest.open(\"GET\", lookupRequest, true); ajaxRequest.send(null); } //--> </script> <!-- AJAX END --> Any ideas why Firefox (and maybe Safari/Opera...i don't have those) is unhappy and what I can do to resolve this? Thanks! :-\
  13. okay...so i got it (mostly). The following works: onLoad="window.opener.ajaxFunction();self.close();return false;" The only problem is (and this could be completely unrelated) that if i execute the function this way in Firefox, it never seems to complete the Ajax request. It wirks perfectly in IE7. Anyone know what the problem may be (i can post the source in a new thread if nobody has ideas without seeing it). This is a pretty standard ajax request, and it is getting stuck in the "loading" loop (in firefox, not in IE): ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4) { if (ajaxRequest.status == 200) { // SUCCESS // the next line inserts retrieved data into a DIV area called <AjaxContentDiv> document.getElementById('AjaxContentDiv').innerHTML=ajaxRequest.responseText; } else { // this might be a 404 if the page is missing (or other error number) alert(\"ERROR: Page status is \" + ajaxRequest.status); return false; } } else { // readyState has changed but <> 4 document.getElementById('AjaxContentDiv').innerHTML = '<img src=\"images/ajax_loading.gif\"> LOADING...'; } Thanks!
  14. So...i have found out that the "opener" window (originally i was calling this the "parent" since i did not know the correct terminology) can apparently be controlled using the following reference: window.opener.document Unfortunately, even armed with this information, i am still not sure how to run my function "ajaxFunction()" on that window. I know i am making progress, but if anyone has time to point me in the right direction or tell me how to use window.opener.document (or something else) to run my function from the popup window, that would be awesome. THANKS!
  15. i am re-posting the above, because the banner ad seems to have resized the source code snippet i provided, so i think it may be easier to read marked as a quote rather than as code: i have a page (happens to be php) that initializes a javascript popup as follows: i want to run a javascript function in the main (parent) window when the popup is closed. This function will reload the content of the window (actually the content of one section of the page using ajax) to reflect the change made with the popup. Basically, when the popup is closed (which will hopefully happen either by a link click or automatically...both using onLoad="self.close();return false;" ) then the main window should execute a function like: ajaxFunction(); i know pretty much nothing about javascript, but i tried the following with no success: onLoad="parent.ajaxFunction();self.close();return false;" Thank you in advance for any help you can provide!
×
×
  • 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.