How to send this ajax request?

-1

Look at this print:

Actuallytheaboveisanajaxrequestalreadysent,andIwanttolearnhowtowriteit,lookhowIdiditanditisnotworking:

$.ajax({url:'linkdeumsitequaisquer.com.br',type:'post',data:{questionId:1,questionKey:"IDENTITY_SAFETYQUESTION_1},
    dataType:'json',
    success:function(res) {
        alert(res);

   }






});

I feel that something is missing, because there is this 0 and 1 there, in case it should be vector within the date right? Something like this I do not know much about theory, there is another thing that people talk about object I also do not know objects relates to javascript not to understanding this, I know object is class car {} in PHP outside I do not know.

But summarizing is: - How to write the request AJAX as it was sent in the image? - What is javascript object in this JSON manipulation business and such     

asked by anonymous 22.12.2017 / 11:17

1 answer

3
  

How to write the AJAX request as it was sent in the image?

Your code has two errors, the first is not to close the quotes, and the second is not to pass an array, so it is not the same as the image, to have the result you are looking for, your code should look like this: p>

$.ajax({ 
    url:'linkdeumsitequaisquer.com.br',
    type:'post',
    data: [{questionId: 1, questionKey: "IDENTITY_SAFETYQUESTION_1"}],
    dataType:'json',
    success:function(res) {
        alert(res);
   }
});

The way you did, you could only send one object at a time, you can send several by inserting each one into [] and separating each by ,

Ex:

data: [{questionId: 1, questionKey: "IDENTITY_SAFETYQUESTION_1"},
       {questionId: 3, questionKey: "IDENTITY_SAFETYQUESTION_3"}]
  

What is object in javascript

I think this link answers this question: How do prototypes work in JavaScript?

  

this JSON manipulation business

And this also answers the last question:
What is JSON? What is it good for and how does it work?

    
22.12.2017 / 12:00