日期:2014-05-16 浏览次数:20636 次
$("#btn").click(function () { urlData = "sum=" + count + urlData; $.ajax({ type: "post", data: urlData + "&callback=?", url: "http://localhost:3638/servertest1/pic.ashx?", dataType: "jsonp", success: function (data) { //客户端jquery预先定义好的callback函数,成功获取跨域服务器上的json数据后,会动态执行这个callback函数 alert(data); alert("OOOOOKKKKKKK") }, error: function () { alert("error"); } });
using System; using System.Web; using System.Data; using System.Collections.Generic; public class pic : IHttpHandler { public void ProcessRequest (HttpContext context) { string strSum = context.Request.Params["sum"]; string result =String.Empty; List<String> listString = new List<string>(); if (null != strSum) { int sum = Convert.ToInt32(strSum); for (int i = 0; i < sum; i++) { string pic = context.Request.Params["pic" + i.ToString()]; int le = pic.Length; pic = System.Web.HttpUtility.UrlDecode(pic); listString.Add(pic); } result = picHelper.Base64StringToImage(listString[0]); } context.Response.ContentType = "text/plain"; context.Response.Write(result);//我想通过这个,把服务器端处理得到的结果,返回给客户端; context.Response.End();
context.Response.Write(context.Request.Form["callback"]+"('"+result+"')");//我想通过这个,把服务器端处理得到的结果,返回给客户端;