开发者

Jquery ajax subsitituting '??'

I am using JQuery 1.5.1.

Sending JSON data (encoded using https://github.com/douglascrockford/JSON-js) to the server

The encoded json looks like this:

var jsonDataObject = "{'IncomingMessages':
                         [
                             {
  开发者_运维技巧                              'Message':     'msg1key'
                                ,'Value':       'value??'
                             }
                         ]
                     }";

My ajax call looks like this:

$.ajax({
    url:           'Message'
    ,global:       false
    ,contentType:  'application/json; charset:utf-8'
    ,type:         'POST'
    ,data:         jsonDataObject
    ,dataType:     'json'
});

Somehow- when the POST request gets sent (have inspected using Chrome developer tools to verify it is not a server side problem, my data has turned into:

{"IncomingMessages":
    [
         {
            'Message':    'msg1key'
            ,'Value':     'valuejQuery151005146652669645846_1302084584797'
         }
    ]
}

It looks as thought the ?? string is being replaced by this jquery value. The value seems to be some sort of counter, as it increments on successive requests.

If anyone has any idea where this could be coming from and what I could do to fix it, it would be much appreciated.


Just found this is referenced here: http://bugs.jquery.com/ticket/8417

It suggests removing

dataType: 'json

From the ajax call will fix it (and it does indeed seem to fix it for me)

Seems pretty counter-intuitive that this would be needed though

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜