Internet Fanclub roteteufel.de

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

ajax / javascript ?

  • Ersteller Ersteller Guest
  • Erstellt am Erstellt am
G

Guest

Guest
Is unter euch einer der schonmal was mit ajax und javascript gemacht hat? hab da ein kleines problemchen und finde den fehler nicht. anbei schonmal der code: ^^




Code:
var xmlHttp = false;



try {

    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");

} catch(e) {

    try {

        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");

    } catch(e) {

        xmlHttp  = false;

    }

}


//War wohl nix, deshalb nun die Methode für Mozilla und Co.

if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {

    xmlHttp = new XMLHttpRequest();

}



function savePos(elementId){

  var pos,element;

  element=document.getElementById(elementId);

  pos=chkPos(element);



  document.getElementById('message').innerHTML = '<b>Position von Element <i>'+elementId+'</i>:'+ pos.x +' / '+ pos.y +'</b>';


  sendData(elementId,pos.x,pos.y);

}


function sendData(elementID,x,y){

  if (xmlHttp) {

      xmlHttp.open('POST', 'db.php');

      xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

      xmlHttp.send('element=' + elementID + '&x='+ x + '&y=' + y);

  } 

}



function chkPos(element){

  var elem=element,

  tagname="",

  x=0,

  y=0;


  while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")){

    y+=elem.offsetTop;

    x+=elem.offsetLeft;

    tagname=elem.tagName.toUpperCase();


    if (tagname=="BODY" || tagname=="HTML")

      elem=0;


    if (typeof(elem)=="object")

      if (typeof(elem.offsetParent)=="object")

        elem=elem.offsetParent;

  }


  pos=new Object();

  pos.x=x;

  pos.y=y;


  return pos;

}




einschlägige communities konnten bis jetzt auch noch nicht helfen, vielleicht gibts ja nen guru hier in diesem bereich
default_biggrin.png
 
Zurück
Oben