跳到主要內容

發表文章

目前顯示的是有「JQuery」標籤的文章

[JQuery] set Select Default

                        var el = $('#SelectID'); // Select the relevant option, de-select any others el.val("Man").attr('selected', true).siblings('option').removeAttr('selected'); // jQM refresh el.selectmenu("refresh", true);

[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...

[jQuery] jQuery Validation

$('#input').validate({ event: [inputEvent], rules:{ [inputname]:{[Rule1],[Rule2]}, }, submitHandler:function(){ ..[function action] }, debug: true, message }); 1. event : JQuery event 2 submitHandler :提交前做一些動作 3. debug ,設為true則不會送出表單 4. rules ,驗證規則   驗證規則的設定 required: true 必填 number: true 只能輸入數字(包括小數) digits:true 只能輸入整數 minValue: 3               不能小於3 maxValue: 10          最大不超過10 rangeValue:[50,100]   數值範圍為50-100 minLength: 5            最小長度 可用於text input,checkbox,select maxLength:   10        最大長度 可用於text input,checkbox,select rangeLength:[5,10]    長度範圍為5至10位(漢字算一個字符) 可用於text input,checkbox,select email:true               電子郵件 equalTo: "#field"      與#field值相同 dateISO:true           日期型,格式為1998/01/22            1999-12-12 5. messag 規則的錯誤訊息

[.Net] Upload image files using ckeditor in Asp.Net

在Asp.net中使用ckeditor作為所件所得的html編輯器, 對於要上傳檔案的部分 ckeditor並沒有提供Free的元件, 不過還好,有其他的高人用.net開發了相關的功能, 並起提供了source code分享給大眾, 本人使用後發現真的很好用, 有興趣的人 到下載Project source code 試用看看吧。

[JQuery] 好用的 圖片輪播程式JQuery Cycle Plugin

發現一個很好用的圖片輪播程式 JQuery Cycle Plugin 可以設定多種播放模式 還能很快的設定出換頁功能 真的是很方便的元件 $('#picker').cycle({   speed:900,    //速度   timeout:4000, //控制輪播時間  }); 其他的option可參考以下 JQuery Cycle Option JQuery Cycle Plugin

[JQuery UI] Autocomplete

很簡單又很方便的JQuery Autocomplete 用來做文章和商品的label很方便 用法超簡單 只要copy以下的javascript 然後修正一下source跟input的ID就行了 <script> $(function() { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } $( "#tags" ) // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB &&...

[Web Service] Web service return json

Webservice 要output JSON格式的資料 在web service中 method 要加上 [ScriptMethod(ResponseFormat:=ResponseFormat.Json)] _ class 要先設定[ScriptService()] 這樣Jquery.ajax才能使用 [web service] Imports System.Net Imports System.IO Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services Imports System.ComponentModel Imports net.gallerys.common.util Imports PLaiN.dll Imports log4net Imports Newtonsoft.Json <System.Web.Services.WebService(Namespace:="http://tempuri.org/")>_ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ <ScriptService()> _ Public Class WebService Inherits System.Web.Services.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End Function <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Function Li...

User JQuery Dialog for Image

<link rel="stylesheet" href="css/ui-lightness/jquery-ui.custom.css" type="text/css" media="all" /> <script language="JavaScript" type="text/JavaScript" src="js/jquery.min.js"></script> <script language="JavaScript" type="text/JavaScript" src="js/jquery-ui.custom.min.js"></script> <script language="JavaScript" type="text/JavaScript"> <!-- function PreviewImage(uri) {   $("#image").attr('src', uri);   $('#dialog').dialog({    hide: true,    modal: true,     resizable: false,    draggable:  true,    width: 'auto',  closeText: 'Title',   position:[200,100]     }); } ---> <div id="dialog" style="display:none; clip: rect(auto,auto,auto,15);" align="center">    <img id="image" src=""  align="absmiddle" ...

JQuery Ajax

  $.ajax({              type: "post",              url: "URL",              data: { paraName: paraValue},              cache: "false",              success: function(result) {              } //success          });      //$.ajax JQuery Ajax http://www.w3school.com.cn/jquery/ajax_ajax.asp

[asp]asp + JSON

送出Json的asp <!--#include virtual="_lib/JSON_2.0.4.asp"--> <% Dim member Set member = jsObject() member("name") = "MAX" member("surname") = "max" member("message") = "Hello World" member.Flush %> 接收json的asp <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <div id="dname"></div> <script> $.getJSON("jsonTest.asp", function(data) { $("#dname").text(data.name); }); </script> </body> </html> aspjson