问题描述
- 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 />"; } }
解决方案
你回传的时候一起执行不就好了,干嘛要等ajax返回后又执行?
一定有这个要求,你在ajax成功回调里面用ajax在发送一次请求
时间: 2024-12-23 18:44:08