开发者

Get value of the first value pair

开发者 https://www.devze.com 2023-04-03 08:12 出处:网络
I’m trying to get the value of the first value pair from a form submission via AJAX. Here’s what the var Formdata looks like (id=4&name=somename&blah=blah). How do I get the id value of 4? A

I’m trying to get the value of the first value pair from a form submission via AJAX. Here’s what the var Formdata looks like (id=4&name=somename&blah=blah). How do I get the id value of 4? As you can see I was trying several ways but had no luck. Any suggestion would be much appreciated, thanks in advance.

$("#updatetask").validate({     
    submitHandler: function() {
    var formdata = $('#updatetask').serialize();
    var fistkey = formdata.split("&",1);
    var tester = fistkey.slice(-1);
    alert(tester);
    /*
   $.post('/tasks/AJAXupdate', $('#updatetask').serialize(), function(data){
    var retur开发者_StackOverflow中文版nMsg = data.replace(/^\s+|\s+$/g, '');
    if (returnMsg == 'error'){
        alert(returnMsg+': Unable to update task.');
    }else{
        parent.$.fancybox.close();
    }
   });*/
return false;
    }       
});


});


Can't you simply $('#updatetask :input:eq(0)').val() instead of serializing it and parsing the string?

0

精彩评论

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

关注公众号