All,
If I have the following code:
Code:
How can I parse:Code:var http_request = false; function makePOSTRequest(url, parameters, str) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById('myspan').innerHTML = result; window.location.hash = "#picture_id"; resizeAll(); } else { alert('There was a problem with the request.'); } } } function getpic(obj) { var poststr = "picture=" + encodeURI( document.getElementById("picture").value ); makePOSTRequest('getnextpic.php', poststr); }
So I can get a picture_id so I can update my hash on this line?Code:result = http_request.responseText;
I tried this:Code:window.location.hash = "#picture_id";
But it doesn't work. The PHP code is:Code:var imgs = document.getElementsByTagName("img"); for ( var d = 0; d < imgs.length; ++d ) { var img = imgs[d]; if ( img.className == "showpictureid" ) { imgid = imgs[d].getAttribute("id"); //alert("The image id is" + imgid); } }
PHP Code:echo "<div style=\"position:relative;\"><img src=\"uploaded_files/$resultsetstory[image_id]\" class=\"showpictureid\" id=\"$resultsetstory[image_id]\" onclick=\"javascript:getpic(this.myform2);\"></div>";


Reply With Quote
Bookmarks