I have problem with jquery ajax request:
I have one select field and after more then one input fields.
After changing select field, ajax.php get some informations from Database in separate files. How can I call back those values and set it into previos input fields?
I know how to call all values back, and set them in , but not how to set values in separate input fields (data_1, data_2, data_3)
<select name="call_ajax" id="call_ajax">
<input type="text" value="1">Value 1
<input type="text" value="2">Value 2
</select>
<input type="text" id="data_1" value="some old data 1">
<input type="text" id="data_2" value="some old data 2">
<input type="text" id="data_3" value="some old data 3">
<script>
$("#call_ajax").change(function() {
$.ajax
({
type: "POST",
url: "ajax.php",
data: dataString,
cache: false,
success: function(html)
{
$("#what").html(html); // ???????
}
});
});
</script>
ajax.php
<?php
$new_data1 = "new value 1";
$new_data2 = "new value 2";
$new_data3 = "new value 3";
?>
ajax.phpshould return the data in a structured format, e.g. JSON (for preference), XML, CSV, etc. If you return JSON the parameter of thesuccess: functionshould be an object that you can query