Adding a new record to couchdb requires a POST and jQuery supports that verb. So I did the simple
$.post(toc.dbUrl+'techtocs', data, function(data) { alert("Data Loaded: " + data); },"json");
But this got me the "415 unsupported media type" error. I was sending application/json type but I still got the error. So I finally looked up my old code and did this:
$.ajax({ type: 'POST', dataType: 'json', contentType: "application/json", data: JSON.stringify(data), url: toc.dbUrl+'techtocs', success: function(sdata){ //stuff here+ } });
Glad to get it working on this project where techtocs is the database name.
1 comment:
Hey, you deserve a lot of credit for this....been tearing my hair our. Thanks a million.
M
Post a Comment