0

I have a call using jQuery:

rate=$('#rateit99').rateit('value');

I want it to perform using ajax. How could I do?

rateut99 is the ID of element from where value is coming.

Trying to solve this problem.

UPDATE:

        function x()
        {
        rate=rateit();
        }
    function rateit() 
    {
    var element = $('#rateit99');
    alert("rate it :" + element);
    return element;
  }

it alerts : rate it :[object Object]

UPDATE2

start.php

<div class="rateit bigstars" id="rateit99" data-rateit-starwidth="32" data-rateit-starheight="32" style=" position:relative; top:-30px; display:none; left:300px" >
                            </div>

login.php: loads start.php with above elements. All the function those are going to be called are in login.php

1 Answer 1

1

When you call $() you're getting a jQuery object back. So when you're running your script, it's looking for a method called rateit inside the jQuery object, which doesn't exist.

Make rateit a standalone method and try it that wat

function rateit() {
    var element = $('#rateit99');
    // Do your function here
}

EDIT for edited question

 function rateit() {
    var element = $('#rateit99');
    alert("rate it :" + element);
    return element;
  }

The reason you're getting an object back is that $('#rateit99') returns the jQuery object that is referencing the DOM object. So let's say this is an HTML input field. It would contain that element. What you probably want is the value contained in that element. So we need to use the jQuery object to get it

 function rateit() {
    var element = $('#rateit99').val();
    alert("rate it :" + element);
    return element;
  }

Now this function returns the value stored in your HTML element.

Sign up to request clarification or add additional context in comments.

5 Comments

your answer has point to note. But still there's issue. I updated my question please see
I appreciate your help dude. But still not solved. not it does not receive any value in element. element remains empty
Post the HTML element with id="rateid99" then please
Are you wanting to do an AJAX call that populates this div?

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.