adam291086 Posted July 15, 2008 Share Posted July 15, 2008 this is the function where the error is //setting up the ajax update part function createXMLHttp() { if (typeof XMLHttpRequest != 'undefined') return new XMLHttpRequest(); else if (window.ActiveXObject) { var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"]; for (var i = avers.length -1; i >= 0; i--) { try { httpObj = new ActiveXObject(avers[i]); return httpObj; } catch() {} } } throw new Error('XMLHttp (AJAX) not supported'); } this is the error Error: missing identifier in catch Source File: http://adamplowman.co.uk/Rubber_Duckie/moving.js Line: 107, Column: 8 Source Code: } catch() {} Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 put 'e' in catch so it reads catch(e) with the vode around it the same. This is provided the rest of the function is written to do what it's supposed to. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted July 15, 2008 Author Share Posted July 15, 2008 that stopped the error, but i am missing something else as the ajax stuff is stopping the moving of objects around, this is all the page code you can see whats happening here http://adamplowman.co.uk/Rubber_Duckie/moving.php i want the box to move around and the database gets automatically get up dated heres the js code <!-- var ie=document.all; var nn6=document.getElementById&&!document.all; var isdrag=false; var x,y; var dobj; function movemouse(e) { if (isdrag) { dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y; update(); return false; } } function enlarge(e) { if (isdrag) { if(tw - (x -( nn6 ? e.clientX : event.clientX))>100 && th -(y -( nn6 ? e.clientY : event.clientY))>100) { dobj.style.width = nn6 ? tw + e.clientX - x : tw + event.clientX - x; dobj.style.height = nn6 ? th + e.clientY - y : th + event.clientY - y; update(); return false; } if(tw - (x -( nn6 ? e.clientX : event.clientX))>100 && th -(y -( nn6 ? e.clientY : event.clientY))<=100) { dobj.style.width = nn6 ? tw + e.clientX - x : tw + event.clientX - x; dobj.style.height = 100; update(); return false; } if(tw - (x -( nn6 ? e.clientX : event.clientX))<=100 && th -(y -( nn6 ? e.clientY : event.clientY))>100) { dobj.style.width = 100; dobj.style.height = nn6 ? th + e.clientY - y : th + event.clientY - y; update(); return false; } if(tw - (x -( nn6 ? e.clientX : event.clientX))<=100 && th -(y -( nn6 ? e.clientY : event.clientY))<=100) { dobj.style.width = 100; dobj.style.height = 100; update(); return false; } } } function selectmouse(e) { var fobj = nn6 ? e.target : event.srcElement; var topelement = nn6 ? "HTML" : "BODY"; while (fobj.tagName != topelement && fobj.className != "dragme") { fobj = nn6 ? fobj.parentNode : fobj.parentElement; } if (fobj.className=="dragme") { isdrag = true; dobj = fobj; tx = parseInt(dobj.style.left+0); ty = parseInt(dobj.style.top+0); th = parseInt(dobj.style.height+0); tw = parseInt(dobj.style.width+0); x = nn6 ? e.clientX : event.clientX; y = nn6 ? e.clientY : event.clientY; if(y >=(ty+th)-10&&x >=(tx+tw)-10) { document.onmousemove=enlarge; return false; } else { document.onmousemove=movemouse; return false; } } } //setting up the ajax update part function createXMLHttp() { if (typeof XMLHttpRequest != 'undefined') return new XMLHttpRequest(); else if (window.ActiveXObject) { var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"]; for (var i = avers.length -1; i >= 0; i--) { try { httpObj = new ActiveXObject(avers[i]); return httpObj; } catch(e) {} } } throw new Error('XMLHttp (AJAX) not supported'); } function update() { //updating the form to send to the server document.getElementById('div_name').value = dobj.id; document.getElementById('height').value = dobj.style.height; document.getElementById('width').value = dobj.style.width; document.getElementById('top').value = dobj.style.top; document.getElementById('left').value = dobj.style.left; //sending the request to the server //send the first form to the server if (!ajaxObj) ajaxObj = createXMLHttp(); else if (ajaxObj.readyState != 0) ajaxObj.abort(); var url = 'update.php'; ajaxObj.open("POST", url, true); ajaxObj.setRequestHeader("Content-Type" "application/x-www-form-urlencoded"); ajaxObj.onreadystatechange = function() { ajaxObj.processRequest();} var myform = document.forms[0]; var reqBody = getRequestBody(myform); ajaxObj.send(reqBody); ajaxObj.processRequest = function() { if (this.readyState == 4) { if (this.status != 200) { alert('Error : Status '+this.status+' returned.'); } else { var cType = this.getResponseHeader("Content-Type"); if (cType == 'text/xml') { alert(this.responseXML); } else if (cType == 'text/plain') { alert(this.responseText); } else { alert('unknown content type'); } } } } } document.onmousedown=selectmouse; document.onmouseup=new Function("isdrag=false"); //--> Quote Link to comment Share on other sites More sharing options...
adam291086 Posted July 16, 2008 Author Share Posted July 16, 2008 anyone?? Quote Link to comment Share on other sites More sharing options...
adam291086 Posted July 16, 2008 Author Share Posted July 16, 2008 used the example above and now it works.thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.