尝试进行调用并检索一个非常简单的一行JSON文件.
$(document).ready(function() {
jQuery.ajax({
type: 'GET',
url: 'http://wncrunners.com/admin/colors.json' ,
dataType: 'jsonp',
success: function(data) {
alert('success');
}
});
});//end document.ready
Run Code Online (Sandbox Code Playgroud)
这是RAW请求:
GET http://wncrunners.com/admin/colors.json?callback=jQuery16406345664265099913_1319854793396&_=1319854793399 HTTP/1.1
Host: wncrunners.com
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2
Accept: */*
Referer: http://localhost:8888/jquery/Test.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Run Code Online (Sandbox Code Playgroud)
这是RAW响应:
HTTP/1.1 200 OK
Date: Sat, 29 Oct 2011 02:21:24 GMT
Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7d SE/0.5.3
Last-Modified: Fri, 28 Oct 2011 17:48:47 GMT
ETag: "166a2402-10-4eaaeaff"
Accept-Ranges: bytes
Content-Length: 16 …Run Code Online (Sandbox Code Playgroud) 场景 - 150MB文本文件,它是旧电子邮件帐户的导出收件箱.需要解析并从特定用户中提取电子邮件并将其写入新的单个文件.我有适用的代码,它只是顽强的慢.
我正在使用标记字符串来搜索从原始文件开始/结束副本的位置.
这是主要功能:
StreamReader sr = new StreamReader("c:\\Thunderbird_Inbox.txt");
string working = string.Empty;
string mystring = string.Empty;
while (!sr.EndOfStream)
{
while ((mystring = sr.ReadLine()) != null)
{
if (mystring == strBeginMarker)
{
writeLog(mystring);
//read the next line
working = sr.ReadLine();
while( !(working.StartsWith(strEndMarker)))
{
writeLog(working);
working = sr.ReadLine();
}
}
}
}
this.Text = "DONE!!";
sr.Close();
Run Code Online (Sandbox Code Playgroud)
将所选消息写入新文件的函数:
public void writeLog(string sMessage)
{
fw = new System.IO.StreamWriter(path, true);
fw.WriteLine(sMessage);
fw.Flush();
fw.Close();
}
Run Code Online (Sandbox Code Playgroud)
同样,这个过程也有效.我得到了一个很好的输出文件,它只需要很长时间,我确信有办法让它更快.