This works for me:
$.ajax({
url : 'email.pl',
type : "post",
data : { rm :'deleteLetter',
ID : myForm.letterSelect.value
} ,
dataType : 'json',
success : function(ret){
alert (ret.a)
}
} );
I believe the order in which you pass the params to $.ajax matters.
Bruce
--
Bruce McKenzie
http://www.2MinuteExplainer.com
ashutosh bijoor said the following on 3/17/2007 2:45 AM:
> Well deserializing JSON is quite trivial - you just need to do an eval
> on the string to get the object.
> // returns a object
> $("#example").click(function() {
> $.post('http://localhost/e/', function(json) {
> eval "json="+json;
> alert(json);
> }, "json");
> });
>
> -Ashutosh
>
> On 3/17/07, *Bojan* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> wrote:
>
> Hey Chris, I wasn't aware that I could pass in a type to the post()
> func. I tried that and I still got the the data back as a string
> instead of an object. It's in the correct form {'a':4, 'b':3} but
> for some reason it doesn't work. I tried the same with the getJSON()
> funct and it returns an object as it should.
>
> I'm using the following test:
>
> // returns an object
> $("#example").click(function() {
> $.getJSON(' http://localhost/e/', function(json) {
> alert(json);
> });
> });
>
> // returns a string
> $("#example").click(function() {
> $.post('http://localhost/e/', function(json) {
> alert(json);
> }, "json");
> });
>
>
> I'm using the latest jquery.
>
> --
> -bo
>
>
> On 3/17/07, *Chris Domigan* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> You can roll your own:
>
> jQuery.extend({
> postJSON: function( url, data, callback ) {
> return jQuery.post(url, data, callback, "json");
> }
> });
>
> Chris
>
> _______________________________________________
> jQuery mailing list
> [email protected] <mailto:[email protected]>
> http://jquery.com/discuss/
>
>
>
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected] <mailto:[email protected]>
> http://jquery.com/discuss/
>
>
>
>
> --
> Reach1to1 Technologies
> http://www.reach1to1.com
> http://on2.biz
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/