Thursday, July 17, 2014

below is a simple javascript to tell you how to call web service with parameter



var WebReq = null;

function findZip() {
       if (window.XMLHttpRequest)
                WebReq = new XMLHttpRequest();
       else if (window.ActiveXObject) {
                  if (new ActiveXObject("Microsoft.XMLHTTP"))
                       WebReq = new ActiveXObject("Microsoft.XMLHTTP");
                  else
                       WebReq = new ActiveXObject("Msxml2.XMLHTTP");
                  }

var url = "http://xxxxxx/getCityState";
WebReq.open("post", url, true);
WebReq.setRequestHeader("Host","localhost:2508/IVA");
WebReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
WebReq.setRequestHeader("Content-Length","100");
WebReq.onreadystatechange = Result;
}

Javascript in cross browser


I just started investigating on how to code javascript for cross plateform support. This is not complete I will update this blog in later. Please let me know if you are facing any cross plate-form issue so that i could help you.

      AVOID USING IF Browser = 'Internet Explorer' or 'morzilla' or 'chrome' CHECKINGS AS POSSIBLE. 

  •  use attribute function to set/get object/control property
               IE will support you to write script like,

                     MyIMG.src = 'https://www.google.com';

                but above line will not work in chrome and morzilla browsers. so re-write the code like which will work in IE, Morzilla, Chrome , safary etc etc.

                    MyIMG.setAttribute('src',''https://www.google.com');

                     to get property use getAttribute
                     ex: var imgsrc = MyIMG.getAttribute('src');