1

I am getting data to jquery in json form but not able to display in HTML. I don't want use jquery to display. can i access jquery variable in HTML. Please help me, if this possible.

<script type=text/javascript>
$(function() {
  $('#result').bind('input', function() {
    $.getJSON('/prescription1', {
      a: $('input[name="a"]').val()
    }, function(data) {
        console.log(data);
    });
    return false;
  });
});

6
  • As you are getting the data in a JavaScript variable, then you'll have to use JavaScript to pass it to the HTML document. What is wrong with $('#someplace').text(data.myproperty);? Commented May 26, 2016 at 16:30
  • $('#someplace').text(data.myproperty); this displays the complete part. just to be more précised, i want to control things from HTML and not from jquery. Commented May 26, 2016 at 20:05
  • What do you mean with the complete part... is that good or bad? Please provide in your question some sample data, and the result you expect. Please be as concrete as you can. Right now, this is a very vague question. Commented May 26, 2016 at 20:08
  • the complete json. but i need to control every key-value of json. [{"A":1,"B":2}]. let's say i need to access only key "B" and not the complete json. Commented May 26, 2016 at 20:12
  • Not possible with HTML ("hypertext mark up language"). But you already use JavaScript, so why don't you want to use JavaScript.... I don't get it. Commented May 26, 2016 at 20:17

1 Answer 1

1

No, you can't access jquery data using HTML. HTML is a markup language, this means that you can use html for

annotating a document in a way that is syntactically distinguishable from the text.

Now, if you want to avoid jQuery there is a vanilla javascript solution for your problem but you have to use javascript.

You can read this question on Quora to understand the differences between web languages: https://www.quora.com/What-are-the-differences-between-HTML-XML-PHP-CSS-and-JavaScript-in-layman-terms

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

1 Comment

@SatyendraSahani you can upvote my answer if you like it :-)

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.