hong34210 2015-05-05 05:30 采纳率: 97%
浏览 1781
已采纳

ajax传入成功后执行后台方法

做一个网站,再页面读取一段文字后,点击按钮,用ajax将文字传回后台,现在我希望ajax返回成功后,执行另外一段后台方法,
请问有什么好方法吗?

  [WebMethod]
    public static string GetStr(string s)
    {
        linkWord = s;
        return linkWord;
    }

    private void BtCompare()
    {
        //在页面选中一段句子,在某个地方弹出一个按钮,点击按钮,将选中的句子传入到下面的s当中,然后调用方法,将两个东西传入到o.txt和s.txt,然后比较,接着切割句子,最后输出
        //string s = "As a linguist, he acknowledges that all varieties of human language, including non-standard ones like Black English, can be powerfully expressive--there exists no language or dialect in the world that cannot convey complex ideas.";//在前台选中语句,传入到这里

        demo gg = new demo();
        string[] sentence = gg.SentenceDetect(linkWord);
        string otxt = gg.Parse(sentence);//放在o.txt
        FileStream fotxt = new FileStream(@"D:\\parser\\o.txt", FileMode.Create);
        StreamWriter ot = new StreamWriter(fotxt);
        ot.Write(otxt);
        ot.Flush(); //清除缓存
        ot.Close();
        ot.Dispose();
        fotxt.Close();

        DoParser doq = new DoParser();
        string stxt = doq.parser(linkWord);//放在s.txt
        FileStream fstxt = new FileStream(@"D:\\parser\\s.txt", FileMode.Create);
        StreamWriter st = new StreamWriter(fstxt);
        st.Write(stxt);
        st.Flush();
        st.Close();
        st.Dispose();
        fstxt.Close();

        Process p = new Process();
        p.StartInfo.FileName = @"cmd.exe";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.CreateNoWindow = true;
        p.Start();

        string str = "D:\\BCompare\\BCompare.exe @D:\\parser\\BCconsle.txt D:\\parser\\o.txt D:\\parser\\s.txt D:\\学习档案\\Reading\\Reading\\report.html ";//保存到当前目录下
        p.StandardInput.WriteLine(str);
        p.StandardInput.WriteLine();
        p.StandardInput.AutoFlush = true;
        p.StandardInput.WriteLine("exit");
        p.StandardOutput.ReadToEnd();
        p.Close();
        Report.Text = "<iframe src='report.html'frameborder='0' height=350px width=100%></iframe>";

        Utils uu = new Utils();
        //String[] ss = uu.subSentenceASC(s);//先长后短句
        String[] ss = uu.subSentenceDESC(stxt);//先短后长句
        int count = 0;
        foreach (string aa in ss)
        {
            Report.Text += ++count + "、" + aa + "<br />";
        }
    }
  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2015-05-05 05:36
    关注

    你回传的时候一起执行不就好了,干嘛要等ajax返回后又执行?

    一定有这个要求,你在ajax成功回调里面用ajax在发送一次请求

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题