Marverick M. Marverick M. - 1 year ago 72
jQuery Question

loading .php file into textbox using ajax

Hi there good day to you Maam/Sir.
I have a problem with my textbox field which is that I can't load the file in the textbox but I can load it in div

I have this code bellow

setInterval(function(){$('#name').load('name.php');}, 1500);

<input type="text" name="name" id="name"/>

I can't determine what is the problem there. Thank you so much for helping me.

Answer Source

jQuery's .load() loads data from the server and inserts the returned HTML into an element. An <input /> element is not one you can insert HTML into; instead you will need to give it a value by adjusting it's value attribute.

Try something like this instead:

    setInterval(function() {
        $.get('name.php', function (data) {
    }, 1500);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download