json - Weird output coming from express' req.query -


I am calling a AJAX to call server-side process of some nodes.

This is my data object

  var data = {field1: value1, field2: value2}   

And sending data: Data to call using JSON.stringify (data)

In the path of my node , Req.query as follows:

  {'{"field1": "7", "field2": "7"}': ''}   

I can not get the values ​​using req.query.field1 , how can I format this output so that I can move forward?

The problem is not being set properly from your request headings (Content Type: JSON), because You are sending a string.

To show your post that you are using jQuery, you do not need to empower your data, send it as JSON and jQuery, set the right title:

  $ Ajax ({type: post}, url: "/ someurl", data: {field1: "7", field 2: "7"}}) done (function (msg) {warning ("data saved:" + msg );});    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -