<script type="text/javascript">
<!---->
$(function () {
$.ajax({
url: './js/data.json',
type: 'get',
dataType: 'json',
timeout: 1000,
beforeSend: LoadFunction, / / load execution method
Error: erryFunction, //error execution method
Success: succFunction // successful execution method
});
Function LoadFunction() {$("#list").html('Loading...');}
function erryFunction() {alert("error");}
function succFunction(data) {
$("#list").html('');
//eval converts a string into an array of objects
Var json2 = eval(data); //array
console.log(json2["code"]);
let msg1 = json2["msg"];
json2 = json2["data"];
$.each(json2, function (index, item) {
/ / Loop to get data
var imgUrl = json2[index].imgUrl;
var price = json2[index].price;
var name = json2[index].name;
// $("#js_list").html($("#js_list").html() + "<br>" + imgUrl + " - " + price + " - " + name + "<br/>");
$("#js_list").html($("#js_list").html() +
' <div class="col-lg-3 col-md-4 col-xs-4 col-sm-4 col-xs-6 modify-padding product-info">\n' +
' <div class="thumbnail modify-border>\n' +
' <a href="#">\n' +
' <img src="'+imgUrl+'" alt="Product Image">\n' +
' <div class="caption">\n' +
' <h4>'+price+'</h4>\n' +
' <em>'+name+'</em>\n' +
' </div>\n' +
' </a>\n' +
' <div class="clearfix">\n' +
' <a href="#" class="btn btn-danger pull-right">Add to cart</a>\n' +
' </div>\n' +
' </div>\n' +
' </div>\n')
});
}
});
</script>
The front desk jquery+ajax+json passes the value, and the json string is returned after the background processing. How to get the attribute value inside? (Without springmvc annotation) 1. Take attribu...
jQuery ajax pass json array to the background The front end code is as follows: Background code: Here is the params, which is data:{params:JSON.stringify(arr)}. The key of the aqx passed in the parame...
<script type="text/javascript" src="${basepath }/js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button&qu...
First, the front end passed JSON data to the background JS code: Background Control class Java code: Second, pass the FormData form data to the background JS code: Background Control class Java code:...
1. Create a new demo.aspx page. 2. First add a reference to the background file demos.aspx.cs on this page. 3. Method call without parameters. Everyone noticed that this version can't be lower than th...
1. Create a new demo.aspx page. 2. First add a reference in the demos.aspx.cs background file of the page. JS code: Page code: 3. Method call with parameters Background code: JS code: 4. Return...
Why should you request data instead of requesting pages? Answer: The requested data can be used not only by the browser, but also by the client, and the server program does not need to be developed ag...
Implement a chat page Let's take a look at the effect The chat information in the picture is first put in the json data, and the data is taken through Ajax encapsulated by jQuery, and then displayed o...
problem: Passes an array to the background via ajax, which is not accepted in the background. Solution ajax can't pass an array (in fact, it's not possible to try a lot of methods); converts the array...