跳到主要內容

發表文章

[JQuery] ajaxfileUpload.js return JSON format Error

在調整asp.net MVC上傳程式的時候, 發現actionresult return JSON時候,會出現下面的錯誤 SyntaxError: Unexpected token < 仔細查了一下,才發現 Retrun回來的JSON,不是單純的JSON資料而已 還被加上了<pre ......的資料 所以回傳回來後javascript接到就認為格式不正確。 主要原因出在ajaxfileupload.js 的一個判斷上 uploadHttpData: function(r, type) { var data = !type; data = type == "xml" || data ? r.responseXML : r.responseText; // If the type is "script", eval it in global context if (type == "script") jQuery.globalEval(data); // Get the JavaScript object, if JSON is used. if (type == "json") eval("data = " + data); // evaluate scripts within html if (type == "html") jQuery("<div>").html(data).evalScripts(); return data; } 只要將原本的 if (type == "json") eval("data = " + data); 修改成 if (type == "json"){ if (data.inde...

[JSON] asp 中 decode JSON的方法

可以藉由Javascript來處理   <script language="JScript" runat="Server"> function toObject(json) { eval("var o=" + json); return o; } </script> <% Dim json json = "{'poid':'1','username':'abc','email':'user@gallerymax.net'}" Set json = toObject(json) Response.Write json.poid & "<br/>" Response.Write json.username & "<br/>" Response.Write json.email & "<br/>" Set json = Nothing %>

[Mac Word] Mac word docx 在PC上開啟中文化有亂碼

今天收到一個載MAC office 20007 上建立的中文word 檔(.docx) 在PC的電腦上用word 2003(安裝支援docx的patch) 來開啟 會出現都是亂碼 這個時候可以先用PC上內建的wordpad把檔案打開, 會出現正常的中文內容 在另外存檔下來就可以解決亂碼的問題。  

[.Net] String split to Dictionary

Linq提供很方便的方法 可以將string split成dictionary 方法如下: [VB.net] Dim Str As string="Allen$20,Betty$16" Dim v As Dictionary(Of String, Integer) = Str.Split(",").Select(Function(s) s.Split("$")).ToDictionary(Function(i) i(0), Function(i) Integer.Parse(i(1))) [C#] String Str ="Allen$20,Betty$16" Dictionary<string, int> v = Str.Split(",") .Select(s => s.Split("=")) .ToDictionary(i => i[0], i => Integer.Parse(i[1]))

[Windows]WIN 8 PC Install WIN7 / GPT Convert to MBR

要將預先安裝WIN8的機器,改安裝成WIN7 第一個會遇到的問題就是就是WIN 8硬碟採用GPT格式無法安裝WIN 7 這個時候可以在WIN 7安裝過程中 進入系統安裝界面。將 GPT格式轉換成MBR格式 操作如下 使用Win7光盤開機,進入系統安裝界面。 按Shift + F10打開指令視窗。 輸入Diskpart,進入操作界面。 輸入list disk,查看硬碟資訊 。 輸入select disk 0,選擇disk 0 作為目前操作的硬碟 輸入Clean,清空當下硬碟 輸入convert mbr,將硬碟轉換成MBR格式 操作完成,關閉指令視窗,繼續安裝Win7系統