I am a little confused here,I am trying to post data to my node js server using the following code:
$.ajax({type:'POST',
url:'/map',
data:'type=line&geometry='+str,
success:function(msg)
{
console.log(msg);
},
datatype:'json'
});
This is the result here:
{ type: 'line', geometry: 'b~cqCge{b[mv|q@xnyC' }
This is not JSON.I had previously tried to use contentType
and do this like this:
$.ajax({type:'POST',
url:'/map',
data:{type:'line',geometry:str},
success:function(msg)
{
console.log(msg);
},
datatype:'json',
contentType:"application/json"
});
Even this sent the data without any change.I have also tried the above method using the data string from the first one.I have also tried setting processData
to false
along with the methods in the code blocks.
It is important to me that the data be in JSON
and use AJAX
because I am trying to insert into mongodb from node js using mongojs and it fails