如何将我的数据值从json显示到我的视图,我有来自响应的结果
{"data":{"agency":"Jeddah Islamic Port","num_letter":"1","lab_id":"1","id":"1","quantity":"1","sample_tyre":"Truck (tubetype)","manufacturer":"TRANSTONE","trademark":"TRANS 216","origin":"CHINA","size":"12.00R24","loadindex":"","symbol":"","ply":"20","loadkg":"","year":"2016","week":"1","notes":"","status":"1","recalling":"0","conf_res":"","rejection":"","reject_ar":"","remarks":"","need_test":"1","TypeOfRejection":"","print":"0","agencies":"Jeddah Islamic Port","package":"1","letter_date":"2017-02-23","letter_date2":"0000-00-00","recieved_date":"2017-02-23","letter_no":"1","note":"","subCustomer":"","final_result":"","conformity_date":"0000-00-00"},"image":null}
这只是一行,我想从输入文本框中传递数据
例如:
<input type="text" name="agency" value="Jeddah Islamic Port">
<input type="text" name="num_letter" value="1">
控制器:
$result['data'] = $this->sample_photo_model->search_sample_id();
echo json_encode($result);
我的ajax:我在我的ajax中遗漏了一些东西
$.ajax({
url: url,
data: data,
method: 'POST',
dataType: 'json'
success: function(data){
$('#result').html(); //??????
}
});
谢谢你:)
答案 0 :(得分:0)
通过更改标题来尝试此操作..
var myForm = $('my-form');
function submitMyForm () {
myForm.trigger('submit', [true]);
}
$(function () {
myForm.on('submit', function (e, skipRecaptcha) {
if(skipRecaptcha) {
return;
}
e.preventDefault();
grecaptcha.execute();
});
})
答案 1 :(得分:0)
我解决了问题而只是$('#agency')。val(data.data.agency);在我的文本框上的ajax和ID上
$.ajax({
url: url,
data: data,
method: 'POST',
dataType: 'json',
success: function(data){
$('#agency').val(data.data.agency); //add this line to pass the value on my textbox
}
});
//I add ID on my textbox
<input type="text" name="agency" id="agency" value="Jeddah Islamic Port">