Reputation: 6241
I am using Yii.
I have a php file which represents the view.
It has an input field <input type='text' id='client' />
which I want to update after I get a response from the server.
The response should be sent after I enter a value in other field and submit it to the server.
Can you refer me to an example on how to do this?
Thanks.
Upvotes: 0
Views: 58
Reputation: 1683
Or just php:
<form method="post" action="/">
<input type='text' name="client" id='client' value="<?php if(!empty($_POST['client'] )){ echo $_POST['client']; } ?>" />
<input type="submit">
</form>
Upvotes: 1
Reputation: 4432
Send a ajax
request on form submit, receive the json object
from server and assign it to your textbox
. something like this
$('#submitButton').on('click', function(e){
e.preventdefault();
$.post( "ajax/index", function( data ) {
$( "#client" ).val( data.client );
});
});
Upvotes: 1