Using POST in jQuery

How can you use POST in this command?

var answer = $('#answer').val();
jQuery('div.answer_' + answer + ' a.delete_answer')
               .live('click', function(){

This should match this

 div.answer_answerExample a.delete_answer

Upvotes: 0

Views: 211

Answers (3)

ChaosPandion
ChaosPandion

Reputation: 78252

You are completely misusing the post function. What I believe you meant to do is this.

$('div.answer_' + $('#answer').val() + 'a.delete_answer')

On a side note JavaScript is case-sensitive and calling $.POST would also throw object not found error.

See the jQuery Docs for further reference.

http://docs.jquery.com/Ajax/jQuery.post

Upvotes: 1

TheVillageIdiot
TheVillageIdiot

Reputation: 40497

you need to fetch the result from post into some variable then you can use it in your code as follows (from jquery page):

var anaswer;
$.post("YOUR_PAGE", ,
  function(data){
    alert(data.answer); 
    answer = data.answer;
  }, "json");

Upvotes: 2

mck89
mck89

Reputation: 19231

$.POST is a function not a variable that you can concatenate with strings. I don't understand what are you doing but you can't do it in this way. If yuo explain me better what you're tryng to do i can give you my help.

Upvotes: 2

Related Questions