Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:58:10+00:00 2026-05-31T13:58:10+00:00

I’m not sure if returning html is the way to go here but I’m

  • 0

I’m not sure if returning html is the way to go here but I’m not experienced at all with JSON and maybe that’s the answer to my problem.

I have two ul lists with items, they all have a select in them and the first list contains all the items with the selected option equal to cero, the other list has the rest:

<ul id="invlistsinmesa">
  <li id="inv-56">
      <label>Name 1</label>
        <select>
            <option  value="1">Mesa 1</option>
            <option  value="2">Mesa 2</option>
            <option  value="3">Mesa 3</option>
                    <!-- ... -->                               
            <option selected="selected" value="0">Sin mesa</option>
        </select>
       <div class="delete_box"><a href="#invlistsinmesa" class="close">Delete</a></div>                  
 </li><li id="inv-57">
      <label>Name 2</label>
        <select>
            <option  value="1">Mesa 1</option>
            <option  value="2">Mesa 2</option>
            <option  value="3">Mesa 3</option>
                    <!-- ... -->                               
            <option selected="selected" value="0">Sin mesa</option>
        </select>
       <div class="delete_box"><a href="#invlistsinmesa" class="close">Delete</a></div>                  
 </li>
</ul>
<ul id="invlist">
  <li id="inv-36">
      <label>Name 1</label>
        <select>
            <option  value="1">Mesa 1</option>
            <option  value="2">Mesa 2</option>
            <option selected="selected" value="3">Mesa 3</option>
                    <!-- ... -->                               
            <option value="0">Sin mesa</option>
        </select>
       <div class="delete_box"><a href="#invlistsinmesa" class="close">Delete</a></div>                  
 </li><li id="inv-37">
      <label>Name 2</label>
        <select>
            <option selected="selected" value="1">Mesa 1</option>
            <option value="2">Mesa 2</option>
            <option value="3">Mesa 3</option>
                    <!-- ... -->                               
            <option value="0">Sin mesa</option>
        </select>
       <div class="delete_box"><a href="#invlistsinmesa" class="close">Delete</a></div>                  
 </li>
</ul>

As you see there’s a lot of code and it all comes from a database. I have a few ajax calls going on here (deleting, adding new items) but the one I have a problem with is when I change the selected option. This is my code now (on change of the select):

EDIT: Added the click function (it’s not change because I’m using jqTransform to style the selects but it’s the same as using change with a regular select)

$('li[id^="inv-"] div.jqTransformSelectWrapper ul li a').on('click', function(){
  var item=($(this).closest("li[id^='inv-']")).attr('id');
  var id = parseInt(item.replace("inv-", ""));
  var nummesa= ($(this).closest('li')).attr('class');

$.ajax({
  type: "POST",
  url: "ajax-invi.php",
  dataType: "html",
  data: "id="+id,
  success: function(data) {
    if(data>=0){
      if(data!=0){
        noty({"text":"Person has been moved"});
      }else{
        //Here I need to control if the list item needs to 
        //change to the other list or not
      }          
    }else{
      if(data=='-1'){
        noty({"text":"Table is full, person cannot move there","type":"error"});
      }
    }
  }
 }); 
});

In my ajax-invi.php file I query de database to see if the person can move to the new selected option (basically you put people in tables, you can’t place a person in a full table and that needs to be controlled) and I return -1 if the table is full or 0 if it isn’t, but if I need to move it then I have a problem because I’m not returning the html that I need to move.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:58:12+00:00Added an answer on May 31, 2026 at 1:58 pm

    I’m making some assumptions about what you want here, but assuming you want to move the LI from the invlistsinmesa to invlist here is the code you want for moving the data. You don’t need any html returned from your call because the HTML is already present in your document. Assuming the id in your .ajax call is the LI id, such as inv-56 then here is the code:

    var $item = $('#' + id);
    $('#invlist').append('<li id=' + id + '>' + $item.html() + '</li>');
    $item.remove();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.