0

Im trying to load a numeric value from the database into the textbox named jTagLabel. Its from the JTag API, and the way it is set up, the html code is inside of a jquery.

So first I make a jquery statement to load the value of a span called span1 from a php file called tag count. Ive tested this part and it works fine.

$('#jTagLabel.val()').load('tagcount.php #span1');

$('<div style="width:'+options.defaultWidth+'px;height:'+options.defaultHeight+'px"class="jTagDrag">       <div class="jTagSave"><div class="jTagInput"><input type="text" value="" id="jTagLabel"></div><div class="jTagSaveClose"></div><div class="jTagSaveBtn"></div><div style="clear:both"></div></div>').appendTo(overlay);

What im trying to do is make the .load appear as the value=" " of "id=JTagLabel" above. Any and all help is appreciated.

*Note, the Jquery .load statement is written after the div statement, but for this example, i placed it first.

2
  • 3
    $('#jTagLabel.val()') --- "Ive tested this part and it works fine." --- are you kidding? Commented Nov 19, 2012 at 22:39
  • What i meant was that I tested the load statement in plain text html ie (#div).load('tagcount.php #span1'); Commented Nov 19, 2012 at 22:55

1 Answer 1

1

Something like this perhaps?

$.get('tagcount.php', function(data) {
    var span_text = $('<div>')
                    .append(data)
                    .find('#span1').html();

    $('#jTagLabel').val(span_text);
});

That's how .load() does things. It does try to remove <script> tags though.

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

2 Comments

Hey, your posted method seems to grabbing the entire php file, how would i only grab the data from span1.
Oh, sorry, I missed the selector. I updated the answer to use 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.