raducup
raducup

Reputation: 711

How to send variables in jquery.post

I have this object I want to send:

var DATE={"nume":nume,"descriere":descriere,"id_sertar":tempId};

And I am using this function:

$.post("http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",JSON.stringify(DATE),function(data){
      alert(data);
    });

But is not working well. How can I fix this?

Upvotes: 0

Views: 69

Answers (2)

bugwheels94
bugwheels94

Reputation: 31950

If your page is on same server then just don't stringify your DATE

$.post("http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",DATE,function(data){
      alert(data);
    });

If your page is on different server then use server side scripting(like php Curl) with ajax to get data

Upvotes: 1

Nono
Nono

Reputation: 7302

Very simple:

$.post(
"http://students.info.uaic.ro/~calin.chifan/api/compartiment/sertar/add.json",
DATE,function(data){
 alert(data);
});

Upvotes: 0

Related Questions