Hi Jens,

I investigated the CBLite log files and found out that it is an issue with 
jQuery escaping characters. So if you pass a JSON object as data it is 
actually handling it as a String by escaping E.G the brackets. You can 
avoid it by using:

function doPut(purl, pdata, callback, errCallback)
{
    var request = {
        url: purl,
        processData : false,
        type: 'PUT',
        data: pdata,
        contentType: "application/json",
        success: callback,
        error: errCallback
    };
    
    log("Requesting " + JSON.stringify(request)); 

    $.ajax(request);
}

So the  'processData : false' helped me in this case. Also I then had to 
pass my JSON data over as string directly by using JSON.stringify. So the 
solution for me is actually:

/**
 * Helper to execute a HTTP PUT
 */
function doPut(purl, pdata, callback, errCallback)
{
    var strdata = JSON.stringify(pdata);
    
    var request = {
        url: purl,
        processData : false,
        type: 'PUT',
        data: strdata,
        contentType: "application/json",
        success: callback,
        error: errCallback
    };
    
    log("Requesting " + JSON.stringify(request)); 

    $.ajax(request);
}


Am Dienstag, 9. Dezember 2014 16:41:56 UTC schrieb Jens Alfke:
>
> What's the exact URL of the PUT, the exact JSON body, and the exact error 
> message? 
>
> —Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/1268fba5-4d7a-4048-9530-3eb37965f82e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to