ajax json post,jQuery ajax POST json

You are probably passing encoded Unicode characters to decode_json, not binary UTF-8 characters. See here for the issue and two easy potential fixes.

Some other things are that you aren't escaping entity names (I assume those are meant to be entity names in and of themselves, given their associated values) in your data_obj. Instead it is trying to insert the contents of those variables. I'm assuming you wanted those to be the identifiers themselves:

data_obj = { 'id' : n_id, 'links_json' : json_string }

Unless you are simply accessing data already stored on the server using this, you should consider using POST (or PUT) instead, to be more properly RESTful.

Also, GET is performed by appending to the URL, and you need to be aware of:

dataObject, String

Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing.

processData, Boolean

Default: true

By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.

Because the data is URL appended, even if your javascript is trying to send properly binary encoded UTF-8, it may still get translated into encoded Unicode.

Further, datatype is irrelevant for the data you are sending and refers to what data you expect to receive back. I assume you realize this but I wanted to be sure.

So you may want to stringify your data_obj yourself rather than let .ajax do it for you.

Have you tried simply echoing out your received (server side) data raw (without running a json decode) to see what you're receiving server side, and whether it matches what you expected? It's hard to tell what your problem is necessarily without a sample dataset that replicates it for you. I'm assuming it's going to be related to Perl's json_decode and related encoding issues (the first line here), however.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值