开发者

Ajax post not sending through all data

I'm making a ajax call using jQuery

I'm making use of the following options

'type'=>'POST',
'beforeSend'=>'function(){
    $("#loader").addClass("loader").html("Updating...");
    $("#add").attr("disabled","disabled");
    $("#remove").attr("disabled","disabled");
    $("#assign").attr("disabled","disabled");
    var str = "ids:";
    $("#sortable2 li").each(function(){
       if($(this).attr("id") != ""){
        str = str+$(this).attr("id")+"|";

       }
    })
    alert(str)
 }',
'data'=>'js:{group_id:$("#UserGroup_groups").val(),user_id:1}',
'success'=>'function(data,status){
  alert(data)
 }',
'complete'=>'function(){
    $("#add").removeAttr("disabled");
    $("#remove").removeAttr("disabled");
    $("#assign").removeAttr("disabled");
    $("#loader").addClass("loader").html("Update Successful...");
}'

My problem is I have an unordered list with id="sortable2"

I need to get all the id's of the list items and pass them via the ajax calls aswell

<ul id="sortable2">
<li id="1">...</li>
<li id="2">...</li>
<li id="3">...</li>
<li id="5">...</li>
<li id="7">...</li>
<li id="87">...</li>
</ul>

I tried to do this in the before function, but not sure how to pass them together with the value开发者_如何学Cs in the data option?


The easiest way would be to modify the scope of str so it would be visible in 'data'=>{here}. Just declare it before calling sending function.

'data'=>'js:{group_id:$("#UserGroup_groups").val(),user_id:1, ids: str}',

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜