string strResult = ""; try { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8888/xxx.ashx?op=getuserlist&callback=xxx"); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; try { HttpWebResponse HttpWResp = (HttpWebResponse)myRequest.GetResponse(); Stream myStream = HttpWResp.GetResponseStream(); StreamReader sr = new StreamReader(myStream, Encoding.UTF8); StringBuilder strBuilder = new StringBuilder(); while (-1 != sr.Peek()) { strBuilder.Append(sr.ReadLine()); } strResult = strBuilder.ToString(); } catch (Exception exp) { strResult = "错误:" + exp.Message; } } catch (Exception exp) { strResult = "错误:" + exp.Message; }
js经常遇到无法跨域的情况,后台可以试试