JQuerye Giriş
JQuery, Sihirli dolar ($)işağreti ve operasyonlar zinciridir. Aslında Javascript ve CSS bilginiz varsa çok hoşunuza gidebilir.
33,311 Okunma 3 Yorum 07/07/2011 18:40:09 18/02/2014 22:11:40
jQuery Form plugini ile bu işi basitçe yapabiliyoruz. Bu yazımızda php ile bir upload sayfası hazırlayıp jQuery Form ile progres bar da durumunu gösterelim.
Kısaca jQuery Form plugini nedir? ne değildir bir bakalım.
Daha farklı bir Kullanım
ajaxForm a parametre göndererek işlemimizin durumuna göre ne istersek yapabiliyoruz.
beforeSend | fonksiyonu upload işlemi başlamadan önce yapmak istediğimiz işlemler için | |
uploadProgress | fonksiyonu upload işlemimiz devam ederken çalışıyor | |
success | form başarılı bir şekilde upload edildiyse çalışıyor | |
complate | fonksiyonu ise işlem bittiğinde tetikleniyor. |
Şimdi dosya yükleme için kullanacağımız basit bir form tasarlayalım.
beforeSend kısmında bar genişliğini %0 olarak ayarlayoruz ve yuzde divine %0 yazdırıyoruz.
uploadProgress te percentComplate ile işlemin yüzdesini alıyoruz ve bar id li div e genişlik olarak veriyoruz.
success olunca hepsini %100 yapıyoruz.
complate fonksiyonunda ise mesaj kısmına başarılı yazdırıyoruz.
eğer bir hata olduysa da error fonksiyonunda hata olarak belirtelim.
Parametreler:
beforeSerialize
Callback function to be invoked before the form is serialized. This provides an opportunity to manipulate the form before it's values are retrieved. The beforeSerialize
function is invoked with two arguments: the jQuery object for the form, and the Options Object passed into ajaxForm/ajaxSubmit.
beforeSerialize: function($form, options) {
// return false to cancel submit
}
Default value: null
beforeSubmit
Callback function to be invoked before the form is submitted. The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for validating the form data. If the 'beforeSubmit' callback returns false then the form will not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data in array format, the jQuery object for the form, and the Options Object passed into ajaxForm/ajaxSubmit.
beforeSubmit: function(arr, $form, options) {
// The array of form data takes the following form:
// [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
// return false to cancel submit
}
Default value: null
clearForm
Boolean flag indicating whether the form should be cleared if the submit is successful
Default value: null
data
An object containing extra data that should be submitted along with the form.
data: { key1: 'value1', key2: 'value2' }
dataType
Expected data type of the response. One of: null, 'xml', 'script', or 'json'. The dataType
option provides a means for specifying how the server response should be handled. This maps directly to the jQuery.httpData
method. The following values are supported:
'xml': if dataType == 'xml' the server response is treated as XML and the 'success' callback method, if specified, will be passed the responseXML value
'json': if dataType == 'json' the server response will be evaluted and passed to the 'success' callback, if specified
'script': if dataType == 'script' the server response is evaluated in the global context
Default value: null
error
Callback function to be invoked upon error.
forceSync
Boolean value. Set to true to remove short delay before posting form when uploading files (or using the iframe option). The delay is used to allow the browser to render DOM updates prior to performing a native form submit. This improves usability when displaying notifications to the user, such as "Please Wait..."
Default value: false
iframe
Boolean flag indicating whether the form should always target the server response to an iframe. This is useful in conjuction with file uploads. See the File Uploads documentation on the Code Samples page for more info.
Default value: false
iframeSrc
String value that should be used for the iframe's src attribute when/if an iframe is used.
Default value: about:blank
Default value for pages that use https
protocol: javascript:false
iframeTarget
Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server.
Default value: null
replaceTarget
Optionally used along with the the target
option. Set to true
if the target should be replaced or false
if only the target contents should be replaced.
Default value: false
resetForm
Boolean flag indicating whether the form should be reset if the submit is successful
Default value: null
semantic
Boolean flag indicating whether data must be submitted in strict semantic order (slower). Note that the normal form serialization is done in semantic order with the exception of input elements of type="image"
. You should only set the semantic option to true if your server has strict semantic requirements and your form contains an input element of type="image"
.
Default value: false
success
Callback function to be invoked after the form has been submitted. If a 'success' callback function is provided it is invoked after the response has been returned from the server. It is passed the following arguments:
Default value: null
target
Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element.
Default value: null
type
The method in which the form data should be submitted, 'GET' or 'POST'.
Default value: value of form's method
attribute (or 'GET' if none found)
uploadProgress
Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments:
Default value: null
url
URL to which the form data will be submitted.
Default value: value of form's action
attribute
Kaynaklar
JQuery, Sihirli dolar ($)işağreti ve operasyonlar zinciridir. Aslında Javascript ve CSS bilginiz varsa çok hoşunuza gidebilir.
33,311 Okunma 3 Yorum 07/07/2011 18:40:09 18/02/2014 22:11:40
Bu yazıda jQuery kütüphanesi ile AJAX işlemlerinin nasıl yapıldığından bahsedeceğim. Prototype ve MooTools kütüphanelerini de kullanmış biri olarak size söyleyebilirim ki AJAX işlemlerinin en kolay ve esnek bir şekilde jQuery ile yapılabildiğini gördüm. Eminim ki yazının sonunda bu konuda bana hak vereceksiniz, çünkü gerçekten jQuery ile bir AJAX işlemi yapmak çok kolay..
28,153 Okunma Henüz yorum yapılmamış 31/10/2012 02:07:16 31/10/2012 02:07:04
Bir select kutusu içerisindeki optionları ajax ile alıp yüklemek için yapmamız gerekenler.
22,324 Okunma Henüz yorum yapılmamış 30/09/2012 04:44:27 14/01/2019 01:01:03
Jquerynin bize sağlıcağı en büyük kazanç şüpesiz farklı browserlar için tek kod kullanmak.
21,878 Okunma Henüz yorum yapılmamış 26/07/2011 12:12:10 17/10/2016 01:27:42
Jquery kullanırken yardımcı olacak bir kaç detay...
20,996 Okunma Henüz yorum yapılmamış 18/08/2018 13:33:35 11/04/2020 03:22:50
Uygulamada jQuery(Ajax), PHP ve MySQL kullanacağız.
19,735 Okunma 3 Yorum 17/07/2011 00:59:09
Bir nesenin tetiklenmesini sağlayan olay çeşitleri
19,129 Okunma Henüz yorum yapılmamış 15/01/2014 20:55:49
Jquery, javascript ile hep yapmak isteyip, karışık JS programlama dili yüzünden bir türlü yapamadığınız kodlamayı çok kolay ve hızlıca yapmanızı sağlayan javascript kütüphanesidir.Diğer bir güzel yanı da jquery ile yazılan kodun tüm popüler tarayıcılarda sorunsuz çalışmasıdır, sizin kod üzerinde tarayıcı uyumluluğu çalışması yapamanıza gerek yoktur.
18,880 Okunma Henüz yorum yapılmamış 21/06/2011 23:58:55 08/11/2014 23:59:12
JQuery tüm özellikleriyle bu şemalarda saklı.
17,920 Okunma Henüz yorum yapılmamış 03/12/2012 02:27:58 03/12/2012 02:30:15
2,836 Okunma Henüz yorum yapılmamış 31/12/2018 00:11:43 31/12/2018 00:13:04