1 Reply Latest reply: May 10, 2012 7:48 AM by Nitin Khare RSS

    How to pass an variable to xmlhttp.open("GET/POST","xmlfile",true) method

    876192
      Hi ,


      Is it possible to pass a variable instead of providing xml file.

      For example

      let d='<xml>'+
      '<book>'+
      '<name>Basker Ville</name>'+
      '</book>'+
      '</xaml>';

      now is it possible xmlhttp.open("GET",d,true); ?

      Thanks in advance
        • 1. Re: How to pass an variable to xmlhttp.open("GET/POST","xmlfile",true) method
          Nitin Khare
          >
          Is it possible to pass a variable instead of providing xml file.
          I'm not sure what do you mean by providing xml file. The xmlhttp.open() function usage has to be like:
          xmlhttp.open("GET","url",true);
          where the url is for the server resource that you are trying to access (usually a file like php/asp/jsp etc.) and true/false flag denotes whether call has to be asynchronous (true) or synchronous (false) which usually passed as true for making typical AJAX calls. Now in case you want to send some additional data to the server then you may pass it through parameters something like
          xmlhttp.open("GET","url?param1=value1&param2=value2",true);
          Or in case to do a POST like an HTML form post:
          xmlhttp.open("POST","url",true);
          xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
          xmlhttp.send("param1=Value1&param2=Value2");