Answer the question
In order to leave comments, you need to log in
Processing and inserting json data?
Hello dear experts!
There is a problem that cannot be solved. I've already broken my head.
1. There are several containers of the form:
<div id='12'></div><div id='13'></div><div id='14'></div><div id='17'></div>
[{"week_num_return":"14","plan_amount_return":"15","fact_amount_return":"18"},{"week_num_return":"17","plan_amount_return":"13","fact_amount_return":"0"}]
$('.fc-sum-pfp-number').each(function(i, _cell) {
$(json).each(function(i2) {
$(_cell).append(json[i2].plan_amount_return);
});
});
Answer the question
In order to leave comments, you need to log in
<script>
<script>
$(document).ready(function() {
$('.article').click(function(){
var articleView = $(this).parent('.Node').find('.article');
var viewArticle = $(this).parent('.Node').find('.articleBlock');
var url = $(this).attr('data');
$.getJSON(url, function(data){
$.each(data, function(i, field){
var productCount = viewArticle.append('<div class="articleBlocPrice">'+field.price+' руб.</div><div class="articleBlockDote"></div><div class="articleBlockName">'+field.name+'</div><div style="clear:both"></div>');
if ( articleView.attr("data") == productCount ) {
articleView.removeAttr("data")
} else {
articleView.attr("data", productCount);
}
});
});
});
});
</script>
for (var i = 0; i < json.length; i++) {
var data = "some data" //может быть текст или html
$('#' + json[i].week_num_return).append(data);
}
I'll try to insert a related question.
Is it possible to operate with a string with JSON data using MySQL tools?
That is, having the string
{"week_num_return":"17","plan_amount_return":"13","fact_amount_return":"0"}]
only in the query using the muscle to change the value of "week_num_return"?
Writing a regular expression for each request is not an option.
Prepare a line at the input using php - now I do it, but it's inconvenient
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question