H.HISTORY
H.HISTORY

Reputation: 518

jQuery load into inputfield?

I'm trying to load some texts from an external page into my current page inside an input text field.

I am using this code:

$( "#input2" ).load( "external.php #somediv" );

however, this doesn't load anything into my input field!

I tried to load the same data/content from the same page into a div in my current page and it works fine:

$( "#div2" ).load( "external.php #somediv" );

is there something that I need to do?

I even tried this but i'm sure this is wrong:

$( "#input2" ).val(load( "external.php #somediv" ));

could someone please advise on this issue?

Thanks in advance.

Upvotes: 1

Views: 53

Answers (1)

guest271314
guest271314

Reputation: 1

Try using $.get()

$.get("/path/to/html", function(html) {
  $("#input2").val( $(html).find("#somediv").text() )
})

Upvotes: 2

Related Questions