I could be wrong, but I don't think $.post() is deprecated.


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On May 17, 2007, at 4:31 PM, Christopher Jordan wrote:

Also, Brian, $.post() has been deprecated in favor of $.ajax(). where you would write something like:

$.ajax({
    type: 'POST',
    url: 'page.php',
datatype: 'html', // or json, or xml or script depending on what's getting returned data: {'name':'Joe', 'age':'24',...},//also I think you could pass 24 instead of '24' if you wanted.
    success: function(data){
        // do something upon success
    },
    error:function(data){
        // do something if the call fails
    }
});

or you could create your parameter object like this
var params = {};
params.name = 'Joe';
params.age = '24';
params.blah = 'something else';

then in the ajax call you would just say:

...
    data: params,
    success: function(){
    },
...

Anyway I think that's the preferred method now, but I could be wrong. :o)

Cheers,
Chris

Jake McGraw wrote:
$.post() accepts a collection of name/value pairs, I don't think multi-dimensional arrays/objects work, so what you've already suggested:

$post('page.php',{name:'Joe',age:'24'},...);

will work.

- jake

On 5/17/07, Brian Ronk <[EMAIL PROTECTED]> wrote:

This is actually probably more relevant to post() since I can
concatenate the parameters with the link for getJSON(), but here we go
anyway.

I am pulling JSON information from the server for menu links, and then
creating the menu off of that.  Let's say that I have

{page: 'update.php', linkname: 'Update Joe', vars: [{name: 'name',
value: 'Joe'}, {name: 'age', value: '24'}]}

as information that was returned for the link from the server (sorry
if the JSON isn't quite right).  If I were to put this directly in a
link, it wouldn't be a problem, but since I am trying to put the info
into a post() as parameters to pass to the server (the vars), I'm
running into an issue of how to do it.

I was toying with the idea of storing the values in an outside
variable, and just use that in the call: post(' update.php', varlist);
I'm just not sure how that would work.

The API info for getJSON and post both have params (Map) and it looks
like JSON.  I guess the problem is that I'm not sure what Map is, and
how I should be using it.  Should I shorten my vars to just: vars:
{name: 'Joe', age: '24'} and use something like: post('update.php',
json.vars)?  (Where json is the JSON object that is returned).



--
http://www.cjordan.us

Reply via email to