1

I try to parse POST parameters inside jQuery POST from outside something like:

var PARS = 'name: "Donald Duck", city: "Duckburg"';
$.post("demo_test_post.asp",{ PARS },
  function(data,status){
    alert("Data: " + data + "\nStatus: " + status);
  }
);

Of course this doesn't work, I want to know why and how it can be done correctly.

Thank You!

2 Answers 2

3

without seeing the server side of things but i'm going out on a limb and i'm going to say that your 'PARS' variable should be a object instead of a string, and you can pass that directly into the post method as such:

var PARS = {name: 'Donald Duck', city: 'Duckburg'};
$.post('demo_test_post.asp', PARS, function(data, status) {
  alert('Data: ' + data + '\nStatus: ' + status);
});
Sign up to request clarification or add additional context in comments.

Comments

1

Holly cow! I'm an idiot!

it's simply an object, here is the solution:

var PARS = {name: "Donald Duck", city: "Duckburg"};   
$.post("demo_test_post.asp", PARS ,
  function(data,status){
    alert("Data: " + data + "\nStatus: " + status);
  }
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.