T
T
timers2020-05-04 19:21:45
PHP
timers, 2020-05-04 19:21:45

Ajax request, how to pass value?

I make a bunch of goods, i.e. I tie one to the other.

$id = intval( $_REQUEST['id'] );

$list = "";
$result = $db->query( "SELECT * FROM ".PREFIX."_stol_post WHERE id!=''" );
if( $db->num_rows( $result ) > 1 )
  {  
    while( $row = $db->get_row( $results ) )
      {
        $ids = $row['id'];
        $title = htmlspecialchars( stripslashes( $row['title'] ), ENT_QUOTES, $config['charset'] );						
          
$list .= <<<HTML

      

HTML;
      }
  }
    else
  {
    $list = "<option>Нет банков</option>";  
  }


$list = <<<HTML
<form name="mainoffers" method="post" action="" onsubmit="SetFormSubmit( 'mainoffers' ); return false;">
  <div class="col-sm-4">
  <input type="text" id="add_Post_{$id}" value="{$ids}" name="{$ids}" style="text-align: center; width: 50px;" class="form-control"> 				
  </div>
  <div class="col-sm-4">
    <li><a onclick="AddPost( '{$id}' ); return false;" href="#"> связать</a></li>
  </div>
</form>
HTML;

echo $list;

Products are displayed, then the script:
function AddPost( id ){
    
    var Quest = confirm( "Привязать данный товар" );
    if( Quest )
      {
        document.getElementById( "StatusIDPost_" + id ).innerHTML = "привязывается";
        
        $.ajax({
          url: "/ajax/admin/post/add.post.php",
          data: "value=" + value,
          success: function( data ){
            $( "#LightWindow-content" ).html( data );
          },
          dataType: "html",
          type: "POST"
        });
      }
  }


The /add.post.php file itself",

$id = intval( $_REQUEST['id'] );
if( $id )
  {
    $result = $db->query( "SELECT * FROM ".PREFIX."_vaza_post WHERE `id`='{$id}'" );
    if( $db->num_rows( $result ) > 0 )
      {
        while( $row = $db->get_row( $result ) )  
          {
            $db->query( "UPDATE ".PREFIX."_vaza_post SET `vaza_tovar`='{$value}' WHERE `id`='{$id}' LIMIT 1" );
          }
      }
        else
      {
        echoReturn( "Указанный товар не найден, возможно он был удален ранее!" );
      }
  }
    else
  {
    echoReturn( "Не указан идентификатор товара!" );
  }


The problem is that I cannot achieve the transfer of value or name, because the list of goods is loaded from stol_post, and the selected ID is written to a new database. those. I need to write the ID of one product to the database - vaza_product

Who will tell you how to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2020-05-04
@timers

Some kind of mess of letters and scraps of thoughts...
You send by Ajax data: "value=" + value,, and it's not clear where it came from, catch on the server $_REQUEST['id'], which is absent there. What is there to attach to what is even unrealistic to understand ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question