Jump to content

tinfanide

Members
  • Posts

    445
  • Joined

  • Last visited

Everything posted by tinfanide

  1. Please kindly go tohttp://lifelearning.xtreemhost.com/lib.htmlA testing page. Just check the checkbox "Lib1" and do not enter anything in the input boxI have checked if sFound1 is null in the if condition (already commented in the codes,but the table (at the bottom) still returns the null value. Can anyone help me a bit here?Many thanks in advance.
  2. Yes, thanks for your codes.I was doing JSON.parse but after success, I just thought that whether it would be faster if the json data is parsed into a string.As I need to loop through the json array (stored in a .JSON file) for searching purposes through AJAX, that's why I want to test if a JSON string is faster than looping through an array.
  3. Ya just inspired me. Yes, ya're very right. // IE7+ returns:// FF9 returns:found = jsonData.match(/{[^{]*Lib4[^}]*}/i);
  4. I want to extract Have tried:str.match(/[\W]*Lib4[\W]*/); but return nothing. How can I take it out with JavaScript Regular Expression?
  5. Then I just stick to using <table>.Thanks for pointing to the reference. Quirksmod is always a good one.
  6. But it really doesn't work in IE7, <style>.form_style{display: table-cell;width: 250px; height: 40px;}</style></head><body><form name="queries"><div style="display: table;"><div style="display: table-row;"><div class="form_style"><input type="checkbox" name="libraries" value="Lib1" />Lib1<input type="checkbox" name="libraries" value="Lib2" />Lib2<input type="checkbox" name="libraries" value="Lib3" />Lib3<input type="checkbox" name="libraries" value="Lib4" />Lib4<br /><input type="checkbox" name="items" value="Title" />Title<input type="checkbox" name="items" value="Barcode" />Barcode</div><div class="form_style"><input type="input" name="query" value="" /></div></div></div></form>
  7. <form name="queries"><table style="display: table; height: 50px;"> <tr style="display: table-row;"> <td style="display: table-cell; width: 250px;"> <input type="checkbox" name="libraries" value="Lib1" />Lib1 <input type="checkbox" name="libraries" value="Lib2" />Lib2 <input type="checkbox" name="libraries" value="Lib3" />Lib3 <input type="checkbox" name="libraries" value="Lib4" />Lib4 <br /> <input type="checkbox" name="items" value="title" />Title <input type="checkbox" name="items" value="barcode" />Barcode </td> <td style="display:table-cell; width: 100px;"> <input type="input" name="query" value="" /> </td> </tr></table></form> Yes, you are right. But display: table-row only goes with <table>, not <div>.
  8. var b = true;window.onload = function(){(b==true) ? function(){ var c = "Hello!"; func(c); } : null ;}function func(c){document.write("The word is " + c);} It seems that the function cannot be loaded in this tenary operator.Why's that?
  9. <div><form name="queries" style="display: table;"><div style="display: table-cell; width: 250px; height: 200px;"><input type="checkbox" name="libraries" value="Lib1" />Lib1<input type="checkbox" name="libraries" value="Lib2" />Lib2<input type="checkbox" name="libraries" value="Lib3" />Lib3<input type="checkbox" name="libraries" value="Lib4" />Lib4<br /><input type="checkbox" name="items" value="title" />Title<input type="checkbox" name="items" value="barcode" />Barcode</div><div style="display:table-cell; width: 100px; height: 200px;"><input type="input" name="query" value="" /></div></form></div> Any IE8- (in my case IE7) fix for not displaying the table-cells properly?
  10. How's a callback function like?Is it to check the readyState and status of the first AJAX request before going to the second one?
  11. Solve it.It should beif (typeof(jsonData[1][query])!=="undefined" && (jsonData[1][query])!=null){ // something} not jsonData or xmlhttp.responseText that should not be null or "undefined"
  12. var ajax = function(query){xmlhttp = (window.XMLHttpRequest) ? xmlhttp=new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ jsonData = JSON.parse(xmlhttp.responseText); (xmlhttp.readyState==4 && xmlhttp.status==200) ? func(query) : null ; }xmlhttp.open("GET","lib.json",true);xmlhttp.send();} function func(query){ // fail to check an undefined AJAX responseTextif(typeof(xmlhttp.responseText)=="undefined" && xmlhttp.responseText != null){ alert(0); }else { document.getElementById("result").innerHTML = jsonData[1][query]; }} This is the testing page:http://lifelearning.xtreemhost.com/lib.html Just wanna ask how to check an undefined AJAX responseText.Many thanks.
  13. <html><!--php_json.php--><head><script src="json2.js"></script><script src="php.js"></script><script>ajax("php_json.json",function(){oJSON = JSON.parse(xmlhttp.responseText);sJSON = JSON.stringify(oJSON);/*put it hereokay*/});// here, the variable sJSON is undefinedajax("php.php?json="+sJSON,function(){ alert(xmlhttp.responseText); });//</script></head><body></body></html> // php.jsfunction ajax(source,func){xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ (xmlhttp.readyState == 4 && xmlhttp.status == 200) ? func() : null ; }xmlhttp.open("GET",source,true);xmlhttp.send();} wanna ask how to extend the scope of the variable sJSON to be global?
  14. Yes.But I tried clearing the cache and cookies (even for the domain)After the four clear options were checked,there was still nothing that changed.I thought it would be to do with the history setting where I now disable the histroy record option.
  15. Yes, something to do with the history setting in IE9.Thank you.
  16. When testing a webpage,I use IE9 Web Developer (press F12). Say,The first time I did something in Dreamweaver that uploaded the file later to the server. I pressed F12 andIE9 poped out and showed the result.I came back to DW and changed the codes a bit and came back to IE9.This time no matter how many times I had pressed F5 to refresh the webpage, it still stayed on the first result without changing. This does not happen ever in Firefox Console.Could there be a fix for this IE9 problem?
  17. Changin true to false (asyn) does not work. Yes, using a callback does the work. I didn't know how to use a callback, though.Just still don't understand why it works like return and why return does not work in this case.Just a typo (GetJsonData -> getJsonData)Thank you.
  18. The problem lies in, in my honest opinion, the way I return the xmlhttp.responseText.Just ask for help on how to return an ajax object. function ajax(){xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ var jsonData = eval("("+xmlhttp.responseText+")"); (this.readyState == 4 && this.status == 200) ? alert(jsonData[0][0]) : null ;}xmlhttp.open("GET","json.json",true);xmlhttp.send(null);} This does the job, though.
  19. <script>function ajax(){xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ var jsonData = eval("("+xmlhttp.responseText+")"); return (this.readyState == 4 && this.status == 200) ? jsonData[1][1] : null ;}xmlhttp.open("GET","json.json",true);xmlhttp.send(null);} window.onload function func(){document.getElementById(elem).innerHTML = ajax(); // return undefined}</script> Is there a syntax mistake that produces the undefined result?
  20. if (object.focused = true) {// do something} Is there a way to check if an element is focused in JavaScript?
×
×
  • Create New...