weixin_33696106
weixin_33696106
2017-02-22 15:11
采纳率: 0%
浏览 26

通过jQuery将数组发送到PHP

I have the following div tags that are created dynamically:

<div class="inContainer clonado" data-clone="Si" data-idgaleria="3" data-color="c79471 id=" clone2 ">
<div class="inContainer clonado " data-clone="Si " data-idgaleria="4 " data-color="c6578 " id="clone3 ">

Through drag and drop the element moves in the body. Then in the database I try to save the id of the element and its left and top position.

To capture these properties I am forming an arrangement as follows.

$(".clonado").each(function() {
   var posicion = $(this).position();
   divClonados[$(this).attr('id')] =  [$(this).attr('data-idgaleria'),posicion.left,posicion.top];
});

I already explained this, the problem is when I want to send this arrangement to PHP. I am doing it in the following way:

$.ajax({
      url: url,
      type: "POST",
      data:divClonados,                          
      success: function(data) {
         console.log(data);
      }
});

Is this form bad? And how should you receive them in PHP?

图片转代码服务由CSDN问答提供 功能建议

                    

我有以下动态创建的 div 标记:

  

通过拖放,元素在体内移动。 然后在数据库中,我尝试保存该元素的ID及其左侧和顶部位置。

要获取这些属性,我正在形成如下安排。

  $(“。clonado”)。each(function(){
    var posicion = $(this).position();
    divClonados [$(this).attr('id')] = [$(this).attr('data-idgaleria'),posicion.left,posicion.top];
 });
  

 

我已经解释了这一点,问题是当我要将这种安排发送给PHP时。 我正在通过以下方式进行操作:

  $。ajax({
       网址:url,
       输入:“ POST”,
       数据:divClonados,
       成功:功能(数据){
          console.log(data);
       }
 });
  

 

此表格不好吗? 以及如何用PHP接收它们?     

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐