var myDatavar = {x:1, y: 10, g:2}
$.extend(myDatavar,
 {a:1, b:20, c:3},
 {f:1, g:56, h:8}
 // and so on...
);

RESULT:
myDatavar = {
 a:1, b:20, c:3, f:1, g:56, h:8, x:1, y:10
};

Hope that helps...

On Jan 24, 10:17 am, Woutse <[EMAIL PROTECTED]> wrote:
> I've been searching but couldn't find how to add variables to my data
> object.
>
> I want to make an ajax requst with $.ajax, but before i do that, i
> want to 'build'  the myDatavar.
> That looks something like this:
>
> -----------------------------------------------------------------------
> var myDatavar = { name:'woutse', age:'91'} ;
>
> var obj = document.getElementsByName('country');
> for(i=0;i<obj.length;i++)
> {
>      if (obj[i].type=='text')
>      {
>                      if (obj[i].value!=obj[(i-1)].value)
>              {
>                               /// U can see what im trying to de here,
> but this doesnt work
>                  var t = { 'ctr['+obj[i].alt+'] tr' : obj[i].value };
>                 $.merge(myDatavar , t);
>                     }
>       }
>
> }
>
>         $.ajax({
>           type: 'POST',
>           url:'http://www.tinpay.nl/textadmin/save/',
>           data: myDatavar,
>           dataType: 'text',
>           success: function(data) { refreshData();  },
>           error: function () {  alert('error'); }
>         });
>
> So, how to add data to a object-variable?
>
> thanks in advance,
> woutse

Reply via email to