如何在其他网站上加载ajax功能? [英] how can load ajax function in other web site?

查看:83
本文介绍了如何在其他网站上加载ajax功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数来发送请求并获取html网站和 Response.Write html。当网站使用ajax代码时,浏览器无法加载ajax,因为html和 JavaScript 代码是我的网站页面中的response.write如何调用 WebMethod 函数没有 ajax JavaScript ,在C#代码后面?

I have a function to send request and get html web site and Response.Write the html. when the site use ajax code the browser can not load ajax because html and JavaScript code was response.write in my web site page how can call WebMethod function without ajax and JavaScript , in C# code behind?

Tuple<string, System.Net.CookieContainer> tuple = Web_Functions.GetHtmlSourceAndCookies(site ), cookies);
Response.Write(tuple .Item1);

public static Tuple<string, CookieContainer> GetHtmlSourceAndCookies(string Url, CookieContainer cookies)
{
    try
    {
        Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
        HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(Url);
        Request.AllowAutoRedirect = true;
        Request.CookieContainer = cookies;
        Request.UserAgent = "Foo";
        Request.Accept = "*/*";
        using (HttpWebResponse response = (HttpWebResponse)Request.GetResponse())
        {
            Stream ReceiveStream = response.GetResponseStream();
            StreamReader readStream = new StreamReader(ReceiveStream, encode);
            string strWebFramResponse = readStream.ReadToEnd();
            readStream.Close();
            response.Close();
            return Tuple.Create(strWebFramResponse, cookies); 
        }
    }
    catch (WebException ex)
    {
        return Tuple.Create("false", cookies); 
    }
}

推荐答案

这篇关于如何在其他网站上加载ajax功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆