[jQuery] เกี่ยวกับ button

เริ่มโดย find_someone, 08 ธันวาคม 2009, 13:49:59

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

find_someone

คืออยากให้ input buttion disable ตอนส่งข้อมูลไปอ่ะครับแล้วพอรับข้อมูลและแสดงผลเสร็จก็ให้กลับเป็นเหมือนเดิม
ผมใช้ $.post แบบ json ในการส่งรับและแสดงผลข้อมูลครับ :wanwan017:

chanudom

ผมก็ไม่รู้ลองเอาไปดูเอาเองดีกว่าเว็บนี้เลย
http://www.select2web.com/
[direct=http://www.tech4cus.com]ข่าว it[/direct][direct=http://www.tech4cus.com]เว็บ it[/direct][direct=http://www.shoppingmall.co.th]ร้านค้าออนไลน์ฟรี[/direct][direct=http://www.shoppingmall.co.th]ร้านค้าออนไลน์[/direct]

find_someone

อ้างถึงจาก: chanudom ใน 08 ธันวาคม 2009, 14:53:57
ผมก็ไม่รู้ลองเอาไปดูเอาเองดีกว่าเว็บนี้เลย
http://www.select2web.com/
ขอบคุณครับ
แต่ผมอ่านแล้วไม่ค่อยเข้าใจอ่ะครับ :wanwan004:

totiz

ตั้งชื่อ id ให้กับปุ่ม submit หรือ button ตามนี้
อ้างถึง<input id="submit" type="submit">

แล้วก่อน $.post ให้สั่ง

อ้างถึง$("#submit").attr("disabled", "disabled");

find_someone

อ้างถึงจาก: totiz ใน 08 ธันวาคม 2009, 15:43:10
ตั้งชื่อ id ให้กับปุ่ม submit หรือ button ตามนี้
อ้างถึง<input id="submit" type="submit">

แล้วก่อน $.post ให้สั่ง

อ้างถึง$("#submit").attr("disabled", "disabled");
แล้วถ้าส่งเสร็จแล้วจะให้มันกลับมาเป็นแบบเดิมคือไม่ disable อ่ะครับ ทำยังไง :wanwan017:

find_someone

ขอดันขึ้นมานิดนึงนะครับ :wanwan004:

totiz

อ้างถึงจาก: find_someone ใน 08 ธันวาคม 2009, 16:05:31
อ้างถึงจาก: totiz ใน 08 ธันวาคม 2009, 15:43:10
ตั้งชื่อ id ให้กับปุ่ม submit หรือ button ตามนี้
อ้างถึง<input id="submit" type="submit">

แล้วก่อน $.post ให้สั่ง

อ้างถึง$("#submit").attr("disabled", "disabled");
แล้วถ้าส่งเสร็จแล้วจะให้มันกลับมาเป็นแบบเดิมคือไม่ disable อ่ะครับ ทำยังไง :wanwan017:

ถ้าจะยกเลิกก็
$("#submit").removeAttr("disabled");

แหล่งข้อมูล http://docs.jquery.com/Attributes/removeAttr#name

ball6847

เปลี่ยนไปใช้ $.ajax(); แทนครับ เพราะใน option จะสามารถเรียก callback ก่อนและหลัง ajax request ได้ครับ

ดูได้จาก docs ครับ http://docs.jquery.com/Ajax/jQuery.ajax

ตัวอย่างคร่าวๆสำหรับ postJSON

$.ajax({
   url : 'show_me_json.php' ,
   method : 'POST' ,
   data : 'a=123&b=555' ,
   dataType : 'json' ,
   beforeSend : function (xhr)
   {
       // disable button here
   } ,
   complete : function (xhr , status)
   {
       // enable button here
   }
});
We use Ubuntu.

[direct=http://ng-seo.sourcelab.xyz/]AngularJS SEO Experimental[/direct]

find_someone

ขอบคุณครับได้ความรู้เอาไปใช้งานได้เยอะพอสมควรเลยครับ  :wanwan011:

select2web

มาเพิ่มเติมครับ

วิธีใช้และความหมายคำสั่ง attr
http://www.select2web.com/jquery/jquery-attr-command.html

วิธีใช้และความหมายคำสั่ง removeAttr
http://www.select2web.com/jquery/jquery-removeattr-command.html
รับทำธีม smf,wordpress
[email protected]
บทความการเขียนโปรแกรม
select2web.com
บทความเวิร์ดเพรส
select2webstore.com

Rapid-Developer

ผมแนะนำให้อีกเว็บหนึ่งครับผม เป็นบทความ jQuery ภาษาไทยครับ
jQuery in Thailand

ในนั้นมีอธิบายเรื่องการทำงานด้านการจับ Event อยู่ครับน่าจะมีประโยชน์ครับ
--