title: How to get the return value .asp to ajax
body: <p>Why can't I get the return value from .asp?</p>
  
  <p>Here is my js:</p>
  
  <pre><code>$('#loginID').click(function(){ 
    var userID = $("#userId").val();
    var passID = $("#passwordId").val();
  
    var myURL = "http://ipaddress/asp/test2.asp";   
  
    $.ajax({
      type: "GET",    
      url: myURL,
      dataType: "JSON",
      data: {
        username: userID,
        password: passID,
      },
      success: function (response) {
          alert(response);    
      }
    });
  });
  </code></pre>
  
  <p>my .asp:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;!--#include file="JSON_Conv.asp"--&gt;
  &lt;%
  Dim member
  Set member = jsObject()
  
  set conn=Server.CreateObject("ADODB.Connection")
  conn.Open "Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=userid;Initial Catalog=SMS;Data Source=127.0.0.1"       
  set rs = Server.CreateObject("ADODB.recordset")
  rs.Open "SELECT * FROM USER_ID where UserID = '" &amp; Request.QueryString("username") &amp; "' and password = '" &amp; Request.QueryString("password") &amp; "'",conn,1,3      
  if (not rs.EOF) then
      member("userID") = rs("UserID")
      member("idMember") = rs("IDMember")
      member.Flush
  else
      Response.Write(50)           
  end if
  rs.close
  conn.Close 
  %&gt;
  </code></pre>
  
  <p><strong>edit</strong>
  i just notice there's was a problem with my first js, i was doing a cross server ajax, but saw this guide <a href="http://www.codeproject.com/Articles/185506/AJAX-Cross-Origin-HTTP-request" rel="nofollow">http://www.codeproject.com/Articles/185506/AJAX-Cross-Origin-HTTP-request</a> (reference for other people having same problem) dont forget to add the Response.AddHeader "Access-Control-Allow-Origin","*"</p>
  
  <pre><code>$('#loginID').click(function(){ 
  
      var userID = $("#userId").val();
      var passID = $("#passwordId").val();
  
      var myURL = "http://ipaddresss from other server"+userID+"&amp;password="+passID;
  
  
      var cor = null; 
  
      if (window.XMLHttpRequest) {
      cor = new XMLHttpRequest();
      }
      else {
      alert("Your browser does not support Cross-Origin request!");
      return;
      }
      cor.onreadystatechange = function () {
      if (cor.readyState == 4) {
          var loko = cor.responseText;
          var obj = jQuery.parseJSON(loko);
          alert(obj.userID);
  
      }
      };
  
      cor.open('GET', myURL, true);
      cor.withCredential = "true";
      cor.send(null);
  
      });
  </code></pre>
  
  <p>anyway the problem is solved.. just need to improve my script </p>