跳到主要內容

發表文章

目前顯示的是 7月, 2013的文章

[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]))