1. Home
  2. Htmx
  3. Basic
  4. 🌐 āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ⧍: HTTP Methods āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ

🌐 āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ⧍: HTTP Methods āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ

🌐 āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ⧍: HTTP Methods āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ

📚 āĻāχ āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ⧇ āϝāĻž āĻļāĻŋāĻ–āĻŦ⧇āύ:

  • ✅ hx-get – āĻĄā§‡āϟāĻž āφāύāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ hx-post – āĻĄā§‡āϟāĻž āĻĒāĻžāĻ āĻžāύ⧋āϰ āϜāĻ¨ā§āϝ
  • ✅ hx-put – āĻĄā§‡āϟāĻž āφāĻĒāĻĄā§‡āϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ hx-delete – āĻĄā§‡āϟāĻž āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ hx-patch – āφāĻ‚āĻļāĻŋāĻ• āφāĻĒāĻĄā§‡āĻŸā§‡āϰ āϜāĻ¨ā§āϝ
  • ✅ āϕ⧋āύ Method āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ

đŸŽ¯ āĻŽā§‚āϞ āĻŦāĻŋāώāϝāĻŧ:

  • HTTP Methods āĻāϰ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ
  • RESTful API concepts
  • Request/Response handling

âąī¸ āϏāĻŽāϝāĻŧ: ā§Ēā§Ģ-ā§Ŧā§Ļ āĻŽāĻŋāύāĻŋāϟ | 📋 āĻĒā§āϰāϝāĻŧā§‹āϜāύ: āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ā§§ āϏāĻŽā§āĻĒāĻ¨ā§āύ

âš ī¸ āĻĒā§‚āĻ°ā§āĻŦāĻļāĻ°ā§āϤ:

  • āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ā§§ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇
  • Live Server setup āĻ•āϰāĻž āĻĨāĻžāĻ•āϤ⧇ āĻšāĻŦ⧇
  • HTMX āĻāϰ basic concepts āϜāĻžāύāϤ⧇ āĻšāĻŦ⧇

📖 HTTP Methods āĻ•āĻŋ āĻāĻŦāĻ‚ āϕ⧇āύ āϗ⧁āϰ⧁āĻ¤ā§āĻŦāĻĒā§‚āĻ°ā§āĻŖ?

🤔 HTTP Methods āĻāϰ āϏāĻ‚āĻœā§āĻžāĻž:

HTTP Methods āĻšāϞ āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ āϧāϰāύ⧇āϰ requests āϝāĻž āφāĻŽāϰāĻž server āĻ āĻĒāĻžāĻ āĻžāχāĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ method āĻāϰ āφāϞāĻžāĻĻāĻž āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻāĻŦāĻ‚ āĻ•āĻžāϜ āϰāϝāĻŧ⧇āϛ⧇āĨ¤ āĻāϗ⧁āϞ⧋ web āĻāϰ āĻŽā§‚āϞ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻāĻŦāĻ‚ RESTful API āĻāϰ āĻ…āĻ‚āĻļāĨ¤

đŸŽ¯ āϕ⧇āύ āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ Methods āĻĒā§āϰāϝāĻŧā§‹āϜāύ?

  • āĻ¸ā§āĻĒāĻˇā§āϟāϤāĻž: āϕ⧋āύ āϧāϰāύ⧇āϰ operation āĻ•āϰāĻž āĻšāĻšā§āϛ⧇ āϤāĻž āĻŦā§‹āĻāĻž āϝāĻžāϝāĻŧ
  • āύāĻŋāϰāĻžāĻĒāĻ¤ā§āϤāĻž: āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ method āĻāϰ āφāϞāĻžāĻĻāĻž security implications
  • Caching: āĻ•āĻŋāϛ⧁ method cache āĻšāϝāĻŧ, āĻ•āĻŋāϛ⧁ āĻšāϝāĻŧ āύāĻž
  • Idempotency: āĻ•āĻŋāϛ⧁ method āĻāĻ•āĻžāϧāĻŋāĻ•āĻŦāĻžāϰ āϚāĻžāϞāĻžāϞ⧇āĻ“ same result

📊 HTTP Methods āĻāϰ āϏāĻ‚āĻ•ā§āώāĻŋāĻĒā§āϤ āϤ⧁āϞāύāĻž:

MethodāĻ•āĻžāϜāύāĻŋāϰāĻžāĻĒāĻĻIdempotentCache
GETāĻĄā§‡āϟāĻž āφāύāĻžâœ… āĻšā§āϝāĻžāĻâœ… āĻšā§āϝāĻžāĻâœ… āĻšā§āϝāĻžāρ
POSTāĻĄā§‡āϟāĻž āϤ⧈āϰāĻŋ❌ āύāĻžâŒ āύāĻžâŒ āύāĻž
PUTāϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āφāĻĒāĻĄā§‡āĻŸâŒ āύāĻžâœ… āĻšā§āϝāĻžāĻâŒ āύāĻž
DELETEāĻĄā§‡āϟāĻž āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžâŒ āύāĻžâœ… āĻšā§āϝāĻžāĻâŒ āύāĻž
PATCHāφāĻ‚āĻļāĻŋāĻ• āφāĻĒāĻĄā§‡āĻŸâŒ āύāĻžâŒ āύāĻžâŒ āύāĻž

đŸ“Ĩ hx-get – āĻĄā§‡āϟāĻž āφāύāĻžāϰ āϜāĻ¨ā§āϝ

đŸŽ¯ hx-get āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ:

📖 āĻ•āĻŋ āĻ•āϰ⧇:

  • Server āĻĨ⧇āϕ⧇ data/content retrieve āĻ•āϰ⧇
  • Page reload āĻ›āĻžāĻĄāĻŧāĻžāχ content load āĻ•āϰ⧇
  • āϏāĻŦāĻšā§‡āϝāĻŧ⧇ common āĻāĻŦāĻ‚ āύāĻŋāϰāĻžāĻĒāĻĻ HTTP method
  • Browser cache āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇

🔧 āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ:

  • ✅ Page content load āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Search results āĻĻ⧇āĻ–āĻžāύ⧋āϰ āϜāĻ¨ā§āϝ
  • ✅ User profile information āφāύāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Product details load āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Navigation menu items load āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ

đŸ’ģ Practical Examples:

🔹 Example 1: Simple Content Loading


<!-- Main HTML -->
<button hx-get="user-profile.html" 
        hx-target="#profile-section"
        hx-indicator="#loading">
    👤 āĻĒā§āϰ⧋āĻĢāĻžāχāϞ āĻĻ⧇āϖ⧁āύ
</button>

<div id="loading" style="display: none;">âŗ āϞ⧋āĻĄ āĻšāĻšā§āϛ⧇...</div>
<div id="profile-section">āĻāĻ–āĻžāύ⧇ āĻĒā§āϰ⧋āĻĢāĻžāχāϞ āĻĻ⧇āĻ–āĻžāĻŦ⧇</div>

📄 user-profile.html:


<div style="background: #e8f5e8; padding: 20px; border-radius: 8px;">
    <h3>👤 āĻŦā§āϝāĻŦāĻšāĻžāϰāĻ•āĻžāϰ⧀āϰ āĻĒā§āϰ⧋āĻĢāĻžāχāϞ</h3>
    <p><strong>āύāĻžāĻŽ:</strong> āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āϰāĻšāĻŋāĻŽ</p>
    <p><strong>āχāĻŽā§‡āχāϞ:</strong> rahim@example.com</p>
    <p><strong>āϝ⧋āĻ—āĻĻāĻžāύ:</strong> ā§§ā§Ģ āϜāĻžāύ⧁āϝāĻŧāĻžāϰāĻŋ, ⧍ā§Ļ⧍ā§Ē</p>
</div>

🔹 Example 2: Search Functionality


<input type="text" 
       name="search" 
       placeholder="āĻĒāĻŖā§āϝ āϖ⧁āρāϜ⧁āύ..."
       hx-get="search-results.html"
       hx-target="#search-results"
       hx-trigger="keyup changed delay:500ms"
       hx-indicator="#search-loading">

<div id="search-loading" style="display: none;">🔍 āϖ⧁āρāϜāĻ›āĻŋ...</div>
<div id="search-results">āĻāĻ–āĻžāύ⧇ āϏāĻžāĻ°ā§āϚ āϰ⧇āϜāĻžāĻ˛ā§āϟ āĻĻ⧇āĻ–āĻžāĻŦ⧇</div>

🔹 Example 3: Dynamic Navigation


<nav>
    <a href="#" hx-get="home-content.html" hx-target="#main-content">🏠 āĻšā§‹āĻŽ</a>
    <a href="#" hx-get="about-content.html" hx-target="#main-content">â„šī¸ āφāĻŽāĻžāĻĻ⧇āϰ āϏāĻŽā§āĻĒāĻ°ā§āϕ⧇</a>
    <a href="#" hx-get="contact-content.html" hx-target="#main-content">📞 āϝ⧋āĻ—āĻžāϝ⧋āĻ—</a>
</nav>

<main id="main-content">
    āĻŽā§‚āϞ āĻ•āĻ¨ā§āĻŸā§‡āĻ¨ā§āϟ āĻāĻ–āĻžāύ⧇ āϞ⧋āĻĄ āĻšāĻŦ⧇
</main>

📤 hx-post – āĻĄā§‡āϟāĻž āĻĒāĻžāĻ āĻžāύ⧋āϰ āϜāĻ¨ā§āϝ

đŸŽ¯ hx-post āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ:

📖 āĻ•āĻŋ āĻ•āϰ⧇:

  • Server āĻ āύāϤ⧁āύ data āĻĒāĻžāĻ āĻžāϝāĻŧ
  • Form submission āĻāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻšāϝāĻŧ
  • Data body āϤ⧇ āĻĒāĻžāĻ āĻžāϝāĻŧ, URL āĻ āύāϝāĻŧ
  • Cache āĻšāϝāĻŧ āύāĻž

🔧 āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ:

  • ✅ Form submit āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ āύāϤ⧁āύ user registration
  • ✅ Comment/review submit āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ File upload āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Login/authentication āĻāϰ āϜāĻ¨ā§āϝ

đŸ’ģ Practical Examples:

🔹 Example 1: Contact Form


<form hx-post="submit-contact.html" 
      hx-target="#form-response"
      hx-indicator="#form-loading">

    <div style="margin: 10px 0;">
        <label>āύāĻžāĻŽ:</label>
        <input type="text" name="name" required 
               style="width: 100%; padding: 8px; margin-top: 5px;">
    </div>

    <div style="margin: 10px 0;">
        <label>āχāĻŽā§‡āχāϞ:</label>
        <input type="email" name="email" required 
               style="width: 100%; padding: 8px; margin-top: 5px;">
    </div>

    <div style="margin: 10px 0;">
        <label>āĻŦāĻžāĻ°ā§āϤāĻž:</label>
        <textarea name="message" required 
                  style="width: 100%; padding: 8px; margin-top: 5px; height: 100px;"></textarea>
    </div>

    <button type="submit" 
            style="background: #28a745; color: white; padding: 10px 20px; border: none; border-radius: 5px;">
        📧 āĻŦāĻžāĻ°ā§āϤāĻž āĻĒāĻžāĻ āĻžāύ
    </button>
</form>

<div id="form-loading" style="display: none;">📤 āĻĒāĻžāĻ āĻžāύ⧋ āĻšāĻšā§āϛ⧇...</div>
<div id="form-response"></div>

📄 submit-contact.html:


<div style="background: #d4edda; padding: 20px; border-radius: 8px; border-left: 4px solid #28a745; margin-top: 15px;">
    <h3>✅ āĻŦāĻžāĻ°ā§āϤāĻž āϏāĻĢāϞāĻ­āĻžāĻŦ⧇ āĻĒāĻžāĻ āĻžāύ⧋ āĻšāϝāĻŧ⧇āĻ›īŋŊīŋŊ!</h3>
    <p>āϧāĻ¨ā§āϝāĻŦāĻžāĻĻ! āφāĻŽāϰāĻž āĻļā§€āĻ˜ā§āϰāχ āφāĻĒāύāĻžāϰ āϏāĻžāĻĨ⧇ āϝ⧋āĻ—āĻžāϝ⧋āĻ— āĻ•āϰāĻŦāĨ¤</p>
    <p><strong>āĻĒāĻžāĻ āĻžāύ⧋āϰ āϏāĻŽāϝāĻŧ:</strong> <span id="submit-time"></span></p>
    <script>
        document.getElementById('submit-time').textContent = new Date().toLocaleString('bn-BD');
    </script>
</div>

🔹 Example 2: User Registration


<form hx-post="register-user.html" 
      hx-target="#registration-result"
      hx-indicator="#reg-loading">

    <h3>👤 āύāϤ⧁āύ āĻ…ā§āϝāĻžāĻ•āĻžāωāĻ¨ā§āϟ āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύ</h3>

    <input type="text" name="username" placeholder="āχāωāϜāĻžāϰāύ⧇āĻŽ" required
           style="width: 100%; padding: 10px; margin: 5px 0; border: 1px solid #ddd; border-radius: 4px;">

    <input type="email" name="email" placeholder="āχāĻŽā§‡āχāϞ" required
           style="width: 100%; padding: 10px; margin: 5px 0; border: 1px solid #ddd; border-radius: 4px;">

    <input type="password" name="password" placeholder="āĻĒāĻžāϏāĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ" required
           style="width: 100%; padding: 10px; margin: 5px 0; border: 1px solid #ddd; border-radius: 4px;">

    <button type="submit"
            style="width: 100%; background: #007bff; color: white; padding: 12px; border: none; border-radius: 5px; margin-top: 10px;">
        🚀 āĻ…ā§āϝāĻžāĻ•āĻžāωāĻ¨ā§āϟ āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύ
    </button>
</form>

<div id="reg-loading" style="display: none; text-align: center; margin: 10px 0;">
    âŗ āĻ…ā§āϝāĻžāĻ•āĻžāωāĻ¨ā§āϟ āϤ⧈āϰāĻŋ āĻšāĻšā§āϛ⧇...
</div>
<div id="registration-result"></div>

🔹 Example 3: Quick Comment System


<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin: 10px 0;">
    <h4>đŸ’Ŧ āĻŽāĻ¨ā§āϤāĻŦā§āϝ āĻ•āϰ⧁āύ</h4>

    <form hx-post="add-comment.html" 
          hx-target="#comments-list" 
          hx-swap="beforeend"
          hx-indicator="#comment-loading">

        <textarea name="comment" placeholder="āφāĻĒāύāĻžāϰ āĻŽāĻ¨ā§āϤāĻŦā§āϝ āϞāĻŋāϖ⧁āύ..." required
                  style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; height: 80px;"></textarea>

        <div style="margin-top: 10px;">
            <input type="text" name="author" placeholder="āφāĻĒāύāĻžāϰ āύāĻžāĻŽ" required
                   style="padding: 8px; border: 1px solid #ddd; border-radius: 4px; margin-right: 10px;">

            <button type="submit"
                    style="background: #17a2b8; color: white; padding: 8px 16px; border: none; border-radius: 4px;">
                đŸ’Ŧ āĻŽāĻ¨ā§āϤāĻŦā§āϝ āĻĒā§‹āĻ¸ā§āϟ āĻ•āϰ⧁āύ
            </button>
        </div>
    </form>

    <div id="comment-loading" style="display: none; margin-top: 10px;">
        📝 āĻŽāĻ¨ā§āϤāĻŦā§āϝ āĻĒā§‹āĻ¸ā§āϟ āĻšāĻšā§āϛ⧇...
    </div>
</div>

<div id="comments-list">
    <!-- Existing comments will be here -->
</div>

🔄 hx-put – āĻĄā§‡āϟāĻž āφāĻĒāĻĄā§‡āϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ

đŸŽ¯ hx-put āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ:

📖 āĻ•āĻŋ āĻ•āϰ⧇:

  • āĻŦāĻŋāĻĻā§āϝāĻŽāĻžāύ resource āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖāĻ­āĻžāĻŦ⧇ replace āĻ•āϰ⧇
  • Idempotent – āĻāĻ•āĻžāϧāĻŋāĻ•āĻŦāĻžāϰ āϚāĻžāϞāĻžāϞ⧇āĻ“ same result
  • āĻĒ⧁āϰ⧋ object/record update āĻ•āϰ⧇
  • RESTful API āĻāϰ āĻ…āĻ‚āĻļ

🔧 āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ:

  • ✅ User profile āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ update āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Product information āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Settings/Configuration update āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Complete record replacement āĻāϰ āϜāĻ¨ā§āϝ

âš–ī¸ PUT vs POST āĻāϰ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ:

  • PUT: Existing resource update āĻ•āϰ⧇
  • POST: āύāϤ⧁āύ resource āϤ⧈āϰāĻŋ āĻ•āϰ⧇
  • PUT: Idempotent (āĻāĻ•āĻžāϧāĻŋāĻ•āĻŦāĻžāϰ āϚāĻžāϞāĻžāϞ⧇āĻ“ same result)
  • POST: Non-idempotent (āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰ āύāϤ⧁āύ result)

đŸ’ģ Practical Examples:

🔹 Example 1: Profile Update


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px;">
    <h3>👤 āĻĒā§āϰ⧋āĻĢāĻžāχāϞ āφāĻĒāĻĄā§‡āϟ āĻ•āϰ⧁āύ</h3>

    <form hx-put="update-profile.html" 
          hx-target="#profile-status"
          hx-indicator="#update-loading">

        <div style="margin: 10px 0;">
            <label>āĻĒā§‚āĻ°ā§āĻŖ āύāĻžāĻŽ:</label>
            <input type="text" name="fullname" value="āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āϰāĻšāĻŋāĻŽ" required
                   style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px;">
        </div>

        <div style="margin: 10px 0;">
            <label>āχāĻŽā§‡āχāϞ:</label>
            <input type="email" name="email" value="rahim@example.com" required
                   style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px;">
        </div>

        <div style="margin: 10px 0;">
            <label>āĻĢā§‹āύ:</label>
            <input type="tel" name="phone" value="+ā§Žā§Žā§Ļā§§ā§­ā§§ā§¨ā§Šā§Ēā§Ģā§Ŧā§­ā§Ž"
                   style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px;">
        </div>

        <div style="margin: 10px 0;">
            <label>āĻ āĻŋāĻ•āĻžāύāĻž:</label>
            <textarea name="address" 
                      style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px; height: 60px;">āĻĸāĻžāĻ•āĻž, āĻŦāĻžāĻ‚āϞāĻžāĻĻ⧇āĻļ</textarea>
        </div>

        <button type="submit"
                style="background: #ffc107; color: #212529; padding: 10px 20px; border: none; border-radius: 5px; font-weight: bold;">
            🔄 āĻĒā§āϰ⧋āĻĢāĻžāχāϞ āφāĻĒāĻĄā§‡āϟ āĻ•āϰ⧁āύ
        </button>
    </form>

    <div id="update-loading" style="display: none; margin-top: 10px;">
        🔄 āφāĻĒāĻĄā§‡āϟ āĻšāĻšā§āϛ⧇...
    </div>
    <div id="profile-status"></div>
</div>

📄 update-profile.html:


<div style="background: #fff3cd; padding: 15px; border-radius: 8px; border-left: 4px solid #ffc107; margin-top: 15px;">
    <h4>✅ āĻĒā§āϰ⧋āĻĢāĻžāχāϞ āϏāĻĢāϞāĻ­āĻžāĻŦ⧇ āφāĻĒāĻĄā§‡āϟ āĻšāϝāĻŧ⧇āϛ⧇!</h4>
    <p>āφāĻĒāύāĻžāϰ āϏāĻŽāĻ¸ā§āϤ āϤāĻĨā§āϝ āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ āĻšāϝāĻŧ⧇āϛ⧇āĨ¤</p>
    <ul>
        <li>✓ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āϤāĻĨā§āϝ āφāĻĒāĻĄā§‡āϟ āĻšāϝāĻŧ⧇āϛ⧇</li>
        <li>✓ āϝ⧋āĻ—āĻžāϝ⧋āϗ⧇āϰ āϤāĻĨā§āϝ āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ āĻšāϝāĻŧ⧇āϛ⧇</li>
        <li>✓ āĻ āĻŋāĻ•āĻžāύāĻž āφāĻĒāĻĄā§‡āϟ āĻšāϝāĻŧ⧇āϛ⧇</li>
    </ul>
    <p><strong>āφāĻĒāĻĄā§‡āĻŸā§‡āϰ āϏāĻŽāϝāĻŧ:</strong> <span id="update-time"></span></p>
    <script>
        document.getElementById('update-time').textContent = new Date().toLocaleString('bn-BD');
    </script>
</div>

🔹 Example 2: Product Information Update


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px;">
    <h3>đŸ“Ļ āĻĒāĻŖā§āϝ⧇āϰ āϤāĻĨā§āϝ āφāĻĒāĻĄā§‡āϟ āĻ•āϰ⧁āύ</h3>

    <form hx-put="update-product.html" 
          hx-target="#product-status"
          hx-indicator="#product-loading">

        <input type="hidden" name="product_id" value="123">

        <div style="margin: 10px 0;">
            <label>āĻĒāĻŖā§āϝ⧇āϰ āύāĻžāĻŽ:</label>
            <input type="text" name="product_name" value="āĻ¸ā§āĻŽāĻžāĻ°ā§āϟ āĻĢā§‹āύ" required
                   style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px;">
        </div>

        <div style="margin: 10px 0;">
            <label>āĻĻāĻžāĻŽ (āϟāĻžāĻ•āĻž):</label>
            <input type="number" name="price" value="25000" required
                   style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px;">
        </div>

        <div style="margin: 10px 0;">
            <label>āĻŦāĻŋāĻŦāϰāĻŖ:</label>
            <textarea name="description" required
                      style="width: 100%; padding: 8px; margin-top: 5px; border: 1px solid #ddd; border-radius: 4px; height: 80px;">āωāĻšā§āϚ āĻŽāĻžāύ⧇āϰ āĻ¸ā§āĻŽāĻžāĻ°ā§āϟ āĻĢā§‹āύ, āĻĻ⧁āĻ°ā§āĻĻāĻžāĻ¨ā§āϤ āĻ•ā§āϝāĻžāĻŽā§‡āϰāĻž āĻāĻŦāĻ‚ āĻĻā§€āĻ°ā§āϘāĻ¸ā§āĻĨāĻžāϝāĻŧā§€ āĻŦā§āϝāĻžāϟāĻžāϰāĻŋ āϏāĻšāĨ¤</textarea>
        </div>

        <button type="submit"
                style="background: #17a2b8; color: white; padding: 10px 20px; border: none; border-radius: 5px;">
            đŸ“Ļ āĻĒāĻŖā§āϝ⧇āϰ āϤāĻĨā§āϝ āφāĻĒāĻĄā§‡āϟ āĻ•āϰ⧁āύ
        </button>
    </form>

    <div id="product-loading" style="display: none; margin-top: 10px;">
        đŸ“Ļ āĻĒāĻŖā§āϝ⧇āϰ āϤāĻĨā§āϝ āφāĻĒāĻĄā§‡āϟ āĻšāĻšā§āϛ⧇...
    </div>
    <div id="product-status"></div>
</div>

đŸ—‘ī¸ hx-delete – āĻĄā§‡āϟāĻž āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžāϰ āϜāĻ¨ā§āϝ

đŸŽ¯ hx-delete āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ:

📖 āĻ•āĻŋ āĻ•āϰ⧇:

  • Server āĻĨ⧇āϕ⧇ resource āĻ¸ā§āĻĨāĻžāϝāĻŧā§€āĻ­āĻžāĻŦ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞ⧇
  • Idempotent – āĻāĻ•āĻžāϧāĻŋāĻ•āĻŦāĻžāϰ āϚāĻžāϞāĻžāϞ⧇āĻ“ same result
  • āϏāĻžāĻŦāϧāĻžāύ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻšāϝāĻŧ āĻ•āĻžāϰāĻŖ data permanently delete āĻšāϝāĻŧ
  • āϏāĻžāϧāĻžāϰāĻŖāϤ confirmation āĻĒā§āϰāϝāĻŧā§‹āϜāύ

🔧 āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ:

  • ✅ User account delete āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Post/Comment remove āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ File delete āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Shopping cart item remove āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ

âš ī¸ āύāĻŋāϰāĻžāĻĒāĻ¤ā§āϤāĻž āĻŦāĻŋāĻŦ⧇āϚāύāĻž:

  • Confirmation: āϏāĻŦāϏāĻŽāϝāĻŧ user confirmation āύāĻŋāύ
  • Authorization: User āĻāϰ permission check āĻ•āϰ⧁āύ
  • Backup: Important data āĻāϰ backup āϰāĻžāϖ⧁āύ
  • Soft Delete: Permanent delete āĻāϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇ soft delete consider āĻ•āϰ⧁āύ

đŸ’ģ Practical Examples:

🔹 Example 1: Delete with Confirmation


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #dee2e6;">
    <h4>📄 āφāĻŽāĻžāϰ āĻĒā§‹āĻ¸ā§āϟ</h4>
    <p>HTMX āĻĻāĻŋāϝāĻŧ⧇ Modern Web Development</p>
    <p><small>āĻĒā§āϰāĻ•āĻžāĻļāĻŋāϤ: ā§§ā§Ģ āϜāĻžāύ⧁āϝāĻŧāĻžāϰāĻŋ, ⧍ā§Ļ⧍ā§Ē</small></p>

    <div style="margin-top: 15px;">
        <button hx-delete="delete-post.html" 
                hx-target="#post-container"
                hx-confirm="āφāĻĒāύāĻŋ āĻ•āĻŋ āύāĻŋāĻļā§āϚāĻŋāϤ āϝ⧇ āĻāχ āĻĒā§‹āĻ¸ā§āϟāϟāĻŋ āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āϚāĻžāύ? āĻāϟāĻŋ āĻ¸ā§āĻĨāĻžāϝāĻŧā§€āĻ­āĻžāĻŦ⧇ āĻŽā§āϛ⧇ āϝāĻžāĻŦ⧇āĨ¤"
                hx-indicator="#delete-loading"
                style="background: #dc3545; color: white; padding: 8px 16px; border: none; border-radius: 4px;">
            đŸ—‘ī¸ āĻĒā§‹āĻ¸ā§āϟ āĻŽā§āϛ⧇ āĻĢ⧇āϞ⧁āύ
        </button>

        <button style="background: #6c757d; color: white; padding: 8px 16px; border: none; border-radius: 4px; margin-left: 10px;">
            âœī¸ āϏāĻŽā§āĻĒāĻžāĻĻāύāĻž āĻ•āϰ⧁āύ
        </button>
    </div>

    <div id="delete-loading" style="display: none; margin-top: 10px; color: #dc3545;">
        đŸ—‘ī¸ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž āĻšāĻšā§āϛ⧇...
    </div>
</div>

📄 delete-post.html:


<div style="background: #f8d7da; padding: 20px; border-radius: 8px; border-left: 4px solid #dc3545; text-align: center;">
    <h4 style="color: #721c24;">✅ āĻĒā§‹āĻ¸ā§āϟ āϏāĻĢāϞāĻ­āĻžāĻŦ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž āĻšāϝāĻŧ⧇āϛ⧇</h4>
    <p style="color: #721c24;">āφāĻĒāύāĻžāϰ āĻĒā§‹āĻ¸ā§āϟāϟāĻŋ āĻ¸ā§āĻĨāĻžāϝāĻŧā§€āĻ­āĻžāĻŦ⧇ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž āĻšāϝāĻŧ⧇āϛ⧇āĨ¤</p>
    <p style="color: #721c24;"><small>āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžāϰ āϏāĻŽāϝāĻŧ: <span id="delete-time"></span></small></p>
    <script>
        document.getElementById('delete-time').textContent = new Date().toLocaleString('bn-BD');
    </script>
</div>

🔹 Example 2: Shopping Cart Item Removal


<div id="cart-items">
    <div class="cart-item" style="background: #f8f9fa; padding: 15px; margin: 10px 0; border-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
        <div>
            <h5>📱 āĻ¸ā§āĻŽāĻžāĻ°ā§āϟ āĻĢā§‹āύ</h5>
            <p>āĻĻāĻžāĻŽ: ⧍ā§Ģ,ā§Ļā§Ļā§Ļ āϟāĻžāĻ•āĻž | āĻĒāϰāĻŋāĻŽāĻžāĻŖ: ā§§āϟāĻŋ</p>
        </div>
        <button hx-delete="remove-cart-item.html" 
                hx-target="closest .cart-item"
                hx-swap="outerHTML"
                hx-confirm="āĻāχ āĻĒāĻŖā§āϝāϟāĻŋ āĻ•āĻžāĻ°ā§āϟ āĻĨ⧇āϕ⧇ āϏāϰāĻŋāϝāĻŧ⧇ āĻĢ⧇āϞāĻŦ⧇āύ?"
                style="background: #dc3545; color: white; padding: 5px 10px; border: none; border-radius: 4px;">
            ❌ āϏāϰāĻžāύ
        </button>
    </div>

    <div class="cart-item" style="background: #f8f9fa; padding: 15px; margin: 10px 0; border-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
        <div>
            <h5>đŸ’ģ āĻ˛ā§āϝāĻžāĻĒāϟāĻĒ</h5>
            <p>āĻĻāĻžāĻŽ: ā§Ģā§Ģ,ā§Ļā§Ļā§Ļ āϟāĻžāĻ•āĻž | āĻĒāϰāĻŋāĻŽāĻžāĻŖ: ā§§āϟāĻŋ</p>
        </div>
        <button hx-delete="remove-cart-item.html" 
                hx-target="closest .cart-item"
                hx-swap="outerHTML"
                hx-confirm="āĻāχ āĻĒāĻŖā§āϝāϟāĻŋ āĻ•āĻžāĻ°ā§āϟ āĻĨ⧇āϕ⧇ āϏāϰāĻŋāϝāĻŧ⧇ āĻĢ⧇āϞāĻŦ⧇āύ?"
                style="background: #dc3545; color: white; padding: 5px 10px; border: none; border-radius: 4px;">
            ❌ āϏāϰāĻžāύ
        </button>
    </div>
</div>

📄 remove-cart-item.html:


<!-- Empty response - item will be removed from DOM -->

💡 āϟāĻŋāĻĒ: āĻāχ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ empty response āĻĒāĻžāĻ āĻžāύ⧋ āĻšāϝāĻŧ āĻ•āĻžāϰāĻŖ hx-swap="outerHTML" āĻĻāĻŋāϝāĻŧ⧇ āĻĒ⧁āϰ⧋ element replace āĻšāϝāĻŧ⧇ āϝāĻžāϝāĻŧāĨ¤


🔧 hx-patch – āφāĻ‚āĻļāĻŋāĻ• āφāĻĒāĻĄā§‡āĻŸā§‡āϰ āϜāĻ¨ā§āϝ

đŸŽ¯ hx-patch āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ:

📖 āĻ•āĻŋ āĻ•āϰ⧇:

  • Resource āĻāϰ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ…āĻ‚āĻļ update āĻ•āϰ⧇
  • PUT āĻāϰ āĻšā§‡āϝāĻŧ⧇ efficient āĻ•āĻžāϰāĻŖ āĻļ⧁āϧ⧁ changed data āĻĒāĻžāĻ āĻžāϝāĻŧ
  • Partial updates āĻāϰ āϜāĻ¨ā§āϝ ideal
  • Network bandwidth save āĻ•āϰ⧇

🔧 āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ:

  • ✅ Status change āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ (Active/Inactive)
  • ✅ Like/Unlike button āĻāϰ āϜāĻ¨ā§āϝ
  • ✅ Priority/Rating change āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ
  • ✅ Single field update āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ

âš–ī¸ PATCH vs PUT āĻāϰ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ:

  • PATCH: āĻļ⧁āϧ⧁ changed fields āĻĒāĻžāĻ āĻžāϝāĻŧ
  • PUT: āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ resource āĻĒāĻžāĻ āĻžāϝāĻŧ
  • PATCH: Bandwidth efficient
  • PUT: Complete replacement

đŸ’ģ Practical Examples:

🔹 Example 1: Status Toggle


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #dee2e6;">
    <h4>👤 āĻŦā§āϝāĻŦāĻšāĻžāϰāĻ•āĻžāϰ⧀: āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āϰāĻšāĻŋāĻŽ</h4>
    <p>āχāĻŽā§‡āχāϞ: rahim@example.com</p>
    <p>āϝ⧋āĻ—āĻĻāĻžāύ: ā§§ā§Ģ āϜāĻžāύ⧁āϝāĻŧāĻžāϰāĻŋ, ⧍ā§Ļ⧍ā§Ē</p>

    <div style="margin-top: 15px;">
        <span>āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ: </span>
        <span id="user-status" style="background: #28a745; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
            ✅ āϏāĻ•ā§āϰāĻŋāϝāĻŧ
        </span>

        <button hx-patch="toggle-status.html" 
                hx-target="#user-status"
                hx-indicator="#status-loading"
                style="background: #ffc107; color: #212529; padding: 6px 12px; border: none; border-radius: 4px; margin-left: 10px;">
            🔄 āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧁āύ
        </button>

        <div id="status-loading" style="display: none; margin-top: 5px; font-size: 12px; color: #6c757d;">
            🔄 āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻšāĻšā§āϛ⧇...
        </div>
    </div>
</div>

📄 toggle-status.html:


<span style="background: #dc3545; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
    ❌ āύāĻŋāĻˇā§āĻ•ā§āϰāĻŋāϝāĻŧ
</span>

🔹 Example 2: Like/Unlike System


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #dee2e6;">
    <h4>📝 HTMX Tutorial Post</h4>
    <p>HTMX āĻĻāĻŋāϝāĻŧ⧇ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ modern web application āϤ⧈āϰāĻŋ āĻ•āϰāĻŦ⧇āύ āϤāĻžāϰ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻ—āĻžāχāĻĄāĨ¤</p>

    <div style="margin-top: 15px; display: flex; align-items: center; gap: 15px;">
        <button hx-patch="toggle-like.html" 
                hx-target="#like-section"
                hx-indicator="#like-loading"
                style="background: #e3f2fd; color: #1976d2; padding: 8px 16px; border: 1px solid #1976d2; border-radius: 20px;">
            👍 āĻĒāĻ›āĻ¨ā§āĻĻ āĻ•āϰ⧁āύ
        </button>

        <div id="like-section">
            <span style="color: #6c757d;">⧍ā§Ģ āϜāύ āĻĒāĻ›āĻ¨ā§āĻĻ āĻ•āϰ⧇āϛ⧇āύ</span>
        </div>

        <div id="like-loading" style="display: none; font-size: 12px; color: #6c757d;">
            👍 āφāĻĒāĻĄā§‡āϟ āĻšāĻšā§āϛ⧇...
        </div>
    </div>
</div>

📄 toggle-like.html:


<span style="color: #1976d2; font-weight: bold;">
    👍 āφāĻĒāύāĻŋ āĻāĻŦāĻ‚ āφāϰāĻ“ ⧍ā§Ģ āϜāύ āĻĒāĻ›āĻ¨ā§āĻĻ āĻ•āϰ⧇āϛ⧇āύ
</span>

🔹 Example 3: Priority Update


<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #dee2e6;">
    <h4>📋 Task: HTMX Documentation āϞ⧇āĻ–āĻž</h4>
    <p>āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ HTMX tutorial series āϤ⧈āϰāĻŋ āĻ•āϰāĻž</p>

    <div style="margin-top: 15px;">
        <span>āĻ…āĻ—ā§āϰāĻžāϧāĻŋāĻ•āĻžāϰ: </span>
        <div id="priority-section" style="display: inline-block;">
            <span style="background: #ffc107; color: #212529; padding: 4px 8px; border-radius: 4px; font-size: 12px;">
                âš ī¸ āĻŽāĻ§ā§āϝāĻŽ
            </span>
        </div>

        <div style="margin-top: 10px;">
            <button hx-patch="set-priority-high.html" 
                    hx-target="#priority-section"
                    hx-indicator="#priority-loading"
                    style="background: #dc3545; color: white; padding: 4px 8px; border: none; border-radius: 4px; font-size: 12px; margin-right: 5px;">
                🔴 āωāĻšā§āϚ
            </button>

            <button hx-patch="set-priority-medium.html" 
                    hx-target="#priority-section"
                    hx-indicator="#priority-loading"
                    style="background: #ffc107; color: #212529; padding: 4px 8px; border: none; border-radius: 4px; font-size: 12px; margin-right: 5px;">
                🟡 āĻŽāĻ§ā§āϝāĻŽ
            </button>

            <button hx-patch="set-priority-low.html" 
                    hx-target="#priority-section"
                    hx-indicator="#priority-loading"
                    style="background: #28a745; color: white; padding: 4px 8px; border: none; border-radius: 4px; font-size: 12px;">
                đŸŸĸ āύāĻŋāĻŽā§āύ
            </button>
        </div>

        <div id="priority-loading" style="display: none; margin-top: 5px; font-size: 12px; color: #6c757d;">
            🔄 āĻ…āĻ—ā§āϰāĻžāϧāĻŋāĻ•āĻžāϰ āφāĻĒāĻĄā§‡āϟ āĻšāĻšā§āϛ⧇...
        </div>
    </div>
</div>

đŸŽ¯ āϕ⧋āύ Method āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ?

📋 Decision Tree – āϕ⧋āύ Method āĻŦ⧇āϛ⧇ āύ⧇āĻŦ⧇āύ:

🤔 āφāĻĒāύāĻŋ āĻ•āĻŋ āĻ•āϰāϤ⧇ āϚāĻžāύ?

đŸ“Ĩ āĻĄā§‡āϟāĻž āφāύāϤ⧇ āϚāĻžāύ?

→ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ: hx-get

  • Page content load āĻ•āϰāĻž
  • Search results āĻĻ⧇āĻ–āĻžāύ⧋
  • User profile information
  • Product details
📤 āύāϤ⧁āύ āĻĄā§‡āϟāĻž āϤ⧈āϰāĻŋ āĻ•āϰāϤ⧇ āϚāĻžāύ?

→ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ: hx-post

  • āύāϤ⧁āύ user registration
  • Comment/review submit
  • Form submission
  • File upload
🔄 āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻĄā§‡āϟāĻž replace āĻ•āϰāϤ⧇ āϚāĻžāύ?

→ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ: hx-put

  • Complete profile update
  • Product information change
  • Settings configuration
  • Full record replacement
đŸ—‘ī¸ āĻĄā§‡āϟāĻž āĻŽā§āϛ⧇ āĻĢ⧇āϞāϤ⧇ āϚāĻžāύ?

→ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ: hx-delete

  • Account deletion
  • Post/Comment removal
  • File deletion
  • Cart item removal
🔧 āĻļ⧁āϧ⧁ āĻ•āĻŋāϛ⧁ field āφāĻĒāĻĄā§‡āϟ āĻ•āϰāϤ⧇ āϚāĻžāύ?

→ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ: hx-patch

  • Status toggle
  • Like/Unlike
  • Priority change
  • Single field update

📊 Real-world Use Cases:

đŸĒ E-commerce Website:

  • GET: Product list, product details, user profile āĻĻ⧇āĻ–āĻžāύ⧋
  • POST: āύāϤ⧁āύ order create, user registration, review submit
  • PUT: Complete profile update, product information change
  • DELETE: Cart item remove, account delete, review delete
  • PATCH: Wishlist toggle, quantity update, status change

📱 Social Media App:

  • GET: News feed, user posts, notifications load
  • POST: āύāϤ⧁āύ post create, comment submit, message send
  • PUT: Complete profile update, post edit
  • DELETE: Post delete, comment remove, friend remove
  • PATCH: Like/unlike, follow/unfollow, status update

📋 Task Management:

  • GET: Task list, project details, team members
  • POST: āύāϤ⧁āύ task create, project create, team invite
  • PUT: Complete task update, project settings
  • DELETE: Task delete, project remove, member remove
  • PATCH: Task status change, priority update, progress update

đŸ—ī¸ RESTful API Concepts

🤔 REST āĻ•āĻŋ?

REST (Representational State Transfer) āĻšāϞ web services design āĻ•āϰāĻžāϰ āĻāĻ•āϟāĻŋ architectural styleāĨ¤ āĻāϟāĻŋ HTTP methods āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ resources āĻāϰ āϏāĻžāĻĨ⧇ interact āĻ•āϰāĻžāϰ standard way āĻĒā§āϰāĻĻāĻžāύ āĻ•āϰ⧇āĨ¤

đŸŽ¯ RESTful API āĻāϰ āĻŽā§‚āϞ āύ⧀āϤāĻŋāĻŽāĻžāϞāĻž:

  • Stateless: āĻĒā§āϰāϤāĻŋāϟāĻŋ request independent
  • Resource-based: āϏāĻŦāĻ•āĻŋāϛ⧁ resource āĻšāĻŋāϏ⧇āĻŦ⧇ treat āĻ•āϰāĻž
  • HTTP Methods: Standard HTTP verbs āĻŦā§āϝāĻŦāĻšāĻžāϰ
  • Uniform Interface: Consistent API design

📋 RESTful URL Structure Examples:

HTTP MethodURLāĻ•āĻžāϜHTMX Example
GET/usersāϏāĻŦ users āĻāϰ listhx-get="/users"
GET/users/123Specific user detailshx-get="/users/123"
POST/usersāύāϤ⧁āύ user āϤ⧈āϰāĻŋhx-post="/users"
PUT/users/123User 123 āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ updatehx-put="/users/123"
PATCH/users/123User 123 āφāĻ‚āĻļāĻŋāĻ• updatehx-patch="/users/123"
DELETE/users/123User 123 deletehx-delete="/users/123"

🔄 Request/Response Handling

📡 HTMX Request/Response Cycle:

1ī¸âƒŖ Request Phase:

  • User interaction (click, submit, keyup etc.)
  • HTMX triggers HTTP request
  • Request headers āĻāĻŦāĻ‚ data āĻĒāĻžāĻ āĻžāύ⧋
  • Loading indicator āĻĻ⧇āĻ–āĻžāύ⧋ (āϝāĻĻāĻŋ āĻĨāĻžāϕ⧇)

2ī¸âƒŖ Server Processing:

  • Server request receive āĻ•āϰ⧇
  • Business logic execute āĻ•āϰ⧇
  • Database operations (āϝāĻĻāĻŋ āĻĒā§āϰāϝāĻŧā§‹āϜāύ)
  • HTML response āϤ⧈āϰāĻŋ āĻ•āϰ⧇

3ī¸âƒŖ Response Phase:

  • Server HTML response āĻĒāĻžāĻ āĻžāϝāĻŧ
  • HTMX response receive āĻ•āϰ⧇
  • Target element āĻ content update āĻ•āϰ⧇
  • Loading indicator hide āĻ•āϰ⧇

🔧 Advanced Request Handling:

📤 Request Headers:


<!-- Custom headers āĻĒāĻžāĻ āĻžāύ⧋ -->
<button hx-post="/api/users" 
        hx-headers='{"X-API-Key": "your-api-key", "Content-Type": "application/json"}'
        hx-target="#result">
    Submit with Headers
</button>

đŸ“Ĩ Response Handling:


<!-- Different response status handling -->
<form hx-post="/submit-form" 
      hx-target="#form-result"
      hx-target-error="#error-message">
    <!-- Form fields -->
</form>

<div id="form-result"></div>
<div id="error-message" style="color: red; display: none;"></div>

🔄 Request Validation:


<!-- Form validation with HTMX -->
<input type="email" 
       name="email" 
       hx-post="/validate-email"
       hx-target="#email-validation"
       hx-trigger="blur"
       placeholder="āχāĻŽā§‡āχāϞ āĻ āĻŋāĻ•āĻžāύāĻž">

<div id="email-validation"></div>

✅ āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ⧍ āϏāĻžāϰāϏāĻ‚āĻ•ā§āώ⧇āĻĒ

🎉 āĻ…āĻ­āĻŋāύāĻ¨ā§āĻĻāύ! āφāĻĒāύāĻŋ HTTP Methods āĻāϰ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻŦāĻŋāώāϝāĻŧ āĻļāĻŋāϖ⧇āϛ⧇āύ!

📚 āφāϜ āϝāĻž āĻļāĻŋāĻ–āϞ⧇āύ:

  • ✅ hx-get: āĻĄā§‡āϟāĻž āφāύāĻžāϰ āϜāĻ¨ā§āϝ – āύāĻŋāϰāĻžāĻĒāĻĻ āĻāĻŦāĻ‚ cacheable
  • ✅ hx-post: āύāϤ⧁āύ āĻĄā§‡āϟāĻž āϤ⧈āϰāĻŋāϰ āϜāĻ¨ā§āϝ – form submission āĻāϰ āϜāĻ¨ā§āϝ ideal
  • ✅ hx-put: āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻĄā§‡āϟāĻž replace āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ – complete updates
  • ✅ hx-delete: āĻĄā§‡āϟāĻž āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻžāϰ āϜāĻ¨ā§āϝ – āϏāĻžāĻŦāϧāĻžāύ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ
  • ✅ hx-patch: āφāĻ‚āĻļāĻŋāĻ• āφāĻĒāĻĄā§‡āĻŸā§‡āϰ āϜāĻ¨ā§āϝ – efficient partial updates
  • ✅ RESTful API concepts āĻāĻŦāĻ‚ best practices
  • ✅ Request/Response handling āĻāϰ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ

đŸŽ¯ āĻŽā§‚āϞ āĻŦāĻŋāώāϝāĻŧāϗ⧁āϞ⧋:

  • 🔹 āĻĒā§āϰāϤāĻŋāϟāĻŋ HTTP Method āĻāϰ āφāϞāĻžāĻĻāĻž āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻāĻŦāĻ‚ āĻŦā§āϝāĻŦāĻšāĻžāϰ
  • 🔹 āϕ⧋āύ Method āĻ•āĻ–āύ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŦ⧇āύ āϤāĻžāϰ decision tree
  • 🔹 Real-world examples āĻāĻŦāĻ‚ practical implementations
  • 🔹 Security considerations āĻāĻŦāĻ‚ best practices
  • 🔹 RESTful API design principles

💡 āϗ⧁āϰ⧁āĻ¤ā§āĻŦāĻĒā§‚āĻ°ā§āĻŖ āϟāĻŋāĻĒāϏ:

  • 🔸 GET: āϏāĻŦāϏāĻŽāϝāĻŧ safe operations āĻāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύ
  • 🔸 POST: āύāϤ⧁āύ resource āϤ⧈āϰāĻŋāϰ āϜāĻ¨ā§āϝ ideal
  • 🔸 PUT vs PATCH: Complete vs Partial update āĻāϰ āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ āĻŦ⧁āĻā§āύ
  • 🔸 DELETE: āϏāĻŦāϏāĻŽāϝāĻŧ confirmation āύāĻŋāύ
  • 🔸 RESTful URLs: Consistent naming convention follow āĻ•āϰ⧁āύ

🚀 āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ⧇:

📖 āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ā§Š: HTMX Attributes āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ

  • đŸŽ¯ hx-target āĻāϰ advanced usage
  • ⚡ hx-trigger āĻāϰ āϏāĻŦ options
  • 🔄 hx-swap āĻāϰ āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ modes
  • 📡 hx-indicator āĻāĻŦāĻ‚ loading states
  • 🔧 hx-headers āĻāĻŦāĻ‚ custom headers
  • ✅ hx-confirm āĻāĻŦāĻ‚ user confirmations

📅 āĻĒā§āϰāĻ¸ā§āϤ⧁āϤāĻŋ: āĻāχ āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ⧇āϰ āϏāĻŦ examples practice āĻ•āϰ⧁āύ āĻāĻŦāĻ‚ āύāĻŋāĻœā§‡āϰ āĻŽāϤ⧋ āĻ•āϰ⧇ modify āĻ•āϰ⧇ āĻĻ⧇āϖ⧁āύ!

đŸƒâ€â™‚ī¸ Practice Exercises:

  1. Contact Form: āĻāĻ•āϟāĻŋ complete contact form āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύ āϏāĻŦ HTTP methods āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇
  2. User Management: User list, create, update, delete functionality implement āĻ•āϰ⧁āύ
  3. Shopping Cart: Add to cart, update quantity, remove items functionality āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύ
  4. Like System: Post like/unlike functionality implement āĻ•āϰ⧁āύ
  5. Status Toggle: User active/inactive status toggle āĻ•āϰāĻžāϰ system āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύ

🎉 āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ ⧍ āϏāĻŽā§āĻĒāĻ¨ā§āύ!

āφāĻĒāύāĻŋ āĻāĻ–āύ HTMX āĻāϰ āϏāĻŦ HTTP Methods expert! 🚀

āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āϟāĻŋāωāĻŸā§‹āϰāĻŋāϝāĻŧāĻžāϞ⧇ āĻĻ⧇āĻ–āĻž āĻšāĻŦ⧇! 👋

Articles

How can we help?