Advertisement
Lucassim

ajax jquery

Jan 8th, 2013
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     //version sin Jquery
  2.  
  3.     function startChat( idToChat, nameToChat ) {
  4.         document.getElementById('postingChat').innerHTML = "";
  5.         lastDateChat = -1;
  6.        
  7.         var xmlhttp;
  8.         if (window.XMLHttpRequest)
  9.         {// code for IE7+, Firefox, Chrome, Opera, Safari
  10.             xmlhttp=new XMLHttpRequest();
  11.         } else {// code for IE6, IE5
  12.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  13.         }
  14.        
  15.         xmlhttp.onreadystatechange=function()
  16.         {
  17.             if (xmlhttp.readyState==4 && xmlhttp.status==200)
  18.             {
  19.                 chatTableName = getNumber(xmlhttp.responseText);
  20.                 loadPreviousChat(); // White if there wasnt any chat before
  21.             }
  22.         }
  23.        
  24.     xmlhttp.open("GET","chatQuery.php?to_id="+idToChat+"&user_id=<? echo $data['user_id']; ?>", true);
  25.         xmlhttp.send();
  26.        
  27.         document.getElementById("person1Img").src = "https://graph.facebook.com/"+idToChat+"/picture";
  28.         document.getElementById("person1Name").innerHTML = nameToChat;
  29.         document.getElementById("person1").style.visibility = "visible";
  30.     }
  31.  
  32. */
  33. ***************************************************************************************************
  34. */
  35.     //Lo mismo con JQuery
  36.  
  37. function startChat( idToChat, nameToChat ) {
  38.         document.getElementById('postingChat').innerHTML = "";
  39.         lastDateChat = -1;
  40.        
  41.         $.ajax({
  42.                 type: "GET",
  43.                 url: "chatQuery.php?to_id="+idToChat+"&user_id=<? echo $data['user_id']; ?>",
  44.                     dataType: "jsonp",
  45.                 success: function (data,status,xmlhttp) {
  46.                             chatTableName = getNumber(xmlhttp.responseText);
  47.                     loadPreviousChat(); // White if there wasnt any
  48.                      },
  49.         });;
  50.    
  51.        
  52.         document.getElementById("person1Img").src = "https://graph.facebook.com/" +idToChat+"/picture";
  53.         document.getElementById("person1Name").innerHTML = nameToChat;
  54.         document.getElementById("person1").style.visibility = "visible";
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement