Reputation: 119
Can I do something like this:
$('#myTag').attr('value').load('my_php_file.php');
Upvotes: 0
Views: 92
Reputation: 1039160
No, because .attr('value')
returns a string (representing the value of the value
attribute on the DOM element) and it is pretty meaningless to call the .load()
method on a string. You usually call this method on a DOM element. To illustrate your problem, here's what your code is equivalent to:
var value = 'some value';
value.load('my_php_file.php');
Nonesense.
Did you mean:
$.ajax({
url: 'my_php_file.php',
success: function(result) {
$('#myTag').val(result);
}
});
Upvotes: 4