Jump to content


  • Posts

  • Joined

  • Last visited

newrehmi's Achievements


Newbie (1/7)



  1. THanks alot!!!! that help me much!!
  2. hello there, I have some sort of problem with date in javascript... lemme just post my code here... var currDate = new Date();var currDateEnd = new Date(); currDateEnd = currDate;currDateEnd.setDate(currDate.getDate()+7); alert(currDate); //I tried alert currDate here, and looks like this object (currDate) value has been changed to the value of currDateEnd I know there's other way to surpass this problem, but I want to know first why this is happening... Thanks a lot, very much...
  3. newrehmi

    Basic Cms In Php

    true. sometime I paper-pencil it first, then draw it using CSS.
  4. okay guys, hello how are you: I want to simply try using ajax in my codeigniter system. This is what I am trying to do, I ll write the example first: function downloadText(url, callbackFunction){var XMLHttpRequestObject = false;if (window.XMLHttpRequest){XMLHttpRequestObject = new XMLHttpRequest();}else if (window.ActiveXObject){XMLHttpRequestObject = newActiveXObject("Microsoft.XMLHTTP");}if(XMLHttpRequestObject){XMLHttpRequestObject.open("GET", url);XMLHttpRequestObject.onreadystatechange = function(){if (XMLHttpRequestObject.readyState == 4 &&XMLHttpRequestObject.status == 200){callbackFunction(XMLHttpRequestObject.responseText);delete XMLHttpRequestObject;XMLHttpRequestObject = null;}}XMLHttpRequestObject.send(null);}} I tried to run the event downloadText("<?php echo base_url()."my_controller/some_function"; ?>",alert); but seems like it alert nothing..? any method to run ajax request with this type of uri? btw, the actual uri is this:http://cms/index.php/my_controller/some_function". p/s: I echoed "test" in function some_function() Thx!!!
  5. thanks btw guys =) just looking which practice is good as a php scripter, so that I didn't developed a bad habit which will troublesome me later on..
  6. sorry, i've corrected some part.. hope you can see it clearly. Obviously, the statement of the second case is outside of php script.
  7. hello there w3teachers and friends. I have some question. I believe that I actually have wrote like a several tens of thousand line of script. But, just a few weeks ago, I met some script that changed a bit of my belief. Well, simply let me make turn the question into some example: case 1: <?phpif($foo == "foo"){echo "<span>some statement is running</span>";}?> case 2:<?phpif($foo != "foo"){?><span>theres no running statement</span><?php}?> okay, the example script that has changed my belief is the second case. So, my question is:1. which example do you thing is good for practice 2. I can see that sometimes, the second case is easier, but sometimes may burden since I need to write <?php echo ;?> to instill some php in it. Thanks a lot and give a comment!!
  8. urgh, guys, sorry for my mistake!. I mistakenly used the same variable with $comment. Duh... am so stupid... =_+ hahaI corrected the variable now. <?php$user = $_GET['user'];$content = $_GET['comment'];$date = $_GET['date'];$fopen = fopen('comment.xml','r+');while(!feof($fopen)) { $comment = $comment.fgets($fopen); } $thecomment = str_replace('</commentdata>','',$comment);$newcomment = $thecomment.'<comment><user>'.$user.'</user><content>'.$content.'</content><date>'.$date.'</date></comment></commentdata>';fwrite(fopen('comment.xml','w'),$newcomment);fclose($fopen);?> Thanks a lot for answering, btw!!!!
  9. thanks for the answer. yeah. i learned constructing DOM using javascript before (creating element, attribute, node and etc), but I wonder if there's a connection or relation with the tutorial you posted.edit:at the end of the tutorial, did this statement created a new .xml or just echo the xml structure, so i just use responseXML in ajax.echo $xmlDoc->saveXML(); Thanks.
  10. thanks for answering.below is what i meant by scattered, after I submit a new comment:Before submit: <?xml version="1.0" encoding="iso-8859-1"?><commentdata></commentdata> After submit: test<?xml version="1.0" encoding="iso-8859-1"?><commentdata><comment><user>test</user><content>test<?xml version="1.0" encoding="iso-8859-1"?><commentdata></commentdata></content><date>6/8/2011</date></comment></commentdata> it should be working like this (after indent): <?xml version="1.0" encoding="iso-8859-1"?><commentdata> <comment> <user>test</user> <content>test</content> <date>6/8/2011</date> </comment></commentdata> I searched before about DOM serialization, but haven't found a clue about it yet. A simple explanation about what function does it use (like js method and etc), might help.Thanks a lot for your time!
  11. hello there,I have a problem of assigning GET array into a variable, but, without an assignment and I use the array instead, it worked. Below is the example:The example i tried below is working: <?php$fopen = fopen('comment.xml','r+');while(!feof($fopen)) { $comment = $comment.fgets($fopen); }$thecomment = str_replace('</commentdata>','',$comment);$newcomment = $thecomment.'<comment><user>'.$_GET['user'].'</user><content>'.$_GET['comment'].'</content><date>'.$_GET['date'].'</date></comment></commentdata>';fwrite(fopen('comment.xml','w'),$newcomment);fclose($fopen);?> But when I assign it into a variable first, my xml became scattered with the value of the array around it. Below is the example, when I assign: <?php$user = $_GET['user'];$comment = $_GET['comment'];$date = $_GET['date'];$fopen = fopen('comment.xml','r+');while(!feof($fopen)) { $comment = $comment.fgets($fopen); }$thecomment = str_replace('</commentdata>','',$comment);$newcomment = $thecomment.'<comment><user>'.$user.'</user><content>'.$comment.'</content><date>'.$date.'</date></comment></commentdata>';fwrite(fopen('comment.xml','w'),$newcomment);fclose($fopen);?> Any explanation, why this things happen? Thanks a lot guys!
  12. yes thanks. without your answer, i couldn't trigger my brain anything about it though, i don't know anything about cache.Thanks
  13. Thank you sooo much deirde's father. Now it relief me >,< for knowing what is the problem now.
  14. yeah that's my complete script, the function is called in this part (bold), please re-check: once I submitted a new value, it will call function get(). It worked all the times, but sometimes it fails. I wonder why.Thanks for your times
  15. hello,i've finally been able to make a change to some text using fwrite. But i detected some bug that i didn't understand. First before anything, this is my script: function send() { if (XMLHttpRequest) { var http = new XMLHttpRequest(); } else { var http = new ActiveXObject('Microsoft.XMLHTTP'); } var thetext = document.getElementById('ajax_texttoinsert').value; var date = new Date(); thetext += ', <i>written on '+date.getHours()+':'+date.getMinutes()+'</i>'; http.open('GET','ajax_server.php?thetext='+thetext,true); http.send(null); http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { get() } else if (http.status != 200) { alert('it is not working!!!') } } } function get() { if (XMLHttpRequest) { var http2 = new XMLHttpRequest(); } else { var http2 = new ActiveXObject('Microsoft.XMLHTTP'); } http2.open('GET','the.txt',true); http2.send(null); http2.onreadystatechange = function() { if(http2.readyState == 4 && http2.status == 200) { document.getElementById('ajax_thetextplace').innerHTML = http2.responseText } } } <body onload='get()'> <div id='ajax_thetextplace'></div> <br>Please insert any text below:<br> <input type='text' id='ajax_texttoinsert' /><input id='ajax_submit' type='submit' onclick='send()' /></body> the bug that am talking about is, it's true that the script is running perfect all the time, but sometimes, it's not working. It's like not calling function get() after I submit a new value, but when I reload the page, it run.Is there's something that I still missing like timeout or idling time or anything? or server problem?Thanks alot by the way.
  • Create New...