urbancalli 0 Newbie Poster
curl -H "X-Token: 989afnkj982gbu2h" -X POST  "http://www.domain.com/projects/3434/members/8939587/moves?move\[move\]=after&move\[target\]=3348761" -d "move[move]=after&move[target]=3348761"

above is a curl command to move a member after the target member. I want to convert that curl command to javascript/ajax .. so far, here's what i have done, but it is not working.

var token = "989afnkj982gbu2h";
var url = "http://www.domain.com/projects/3434/members/8939587/moves?move\[move\]=after&move\[target\]=3348761";

$.ajax({
  type: "POST",
  url: url,
  //-X POST  "http://www.domain.com/projects/3434/members/8939587/moves?move\[move\]=after&move\[target\]=3348761"
  data: "move[move]=after&move[target]=3348761", 
  //-d "move[move]=after&move[target]=3348761"
  async: true,
  contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  success: function(){ alert("Successful move!"); }
});

im having some problems in this command:

-H "X-Token: 989afnkj982gbu2h"

I know it should be a custom header or somethings, but how should I sent it with the other data needed based on my code above.

thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.