2014年5月29日

AJAX - Send a Request To a Server example

====================  javascript =======================
function createXMLHttpRequest() {
     try { return new XMLHttpRequest(); } catch (e) { }
     try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { }
     try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { }
           alert("XMLHttpRequest not supported");
         return null;
}


var xmlHttpReq = createXMLHttpRequest();
xmlHttpReq.open("GET", "http://...網址?CIDS="+pics, false);
xmlHttpReq.send(null);
if (xmlHttpReq.responseText == "1")
{
    
}
====================  ashx =======================
using System;
using System.Web;

public class SaveReleasePic : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
            context.Response.Write("1");
      
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

沒有留言:

張貼留言