jquery - How to display json feed to user? -
I have a valid Jason feed which I am using jquery and dragging it to the server by accessing a php file. An example of JSN feed from the PSP file inquiry
{"item": [{"acc_number": "11111", "acc_name": "test account", "demographic": [" "" "Phone": blank, "SMS": blank, "email" acc_name ":" MyAccount ":" 22222 "," some "," some stat "," 99 999 "]," last "third" Null, "Email": Null)], "Total_items": "MyStreet", "MyState", "99999", "Last_thirty": Null, "Phone": Null, "SMS" 80 "," md5sum ":" c7a834d45bdf348abfdcdb95994c7608 "} I am using the code below, though I know through the feed I would not want to bring all the records and fields down, but I could not find anything.
$. Ajax ({type = 'GET', url: 'http: // myurl .com ', datatype:' jason ', user name: myusername, password: mypassword, success: function (data) {var items = []; $ .each (data, function (key, val) {items.push (' & Lt; li id = "'= =" "& gt;' $ '(' & lt; ul / & gt; ', {' class': 'my-new-list', html: items. Join ('')}) .appendTo ('body');}}); Thanks
Any help / suggestion is always appreciated as usual.
Thank you!
$ (document) .ready (function () {testNews ();}); Function testNews () {$ ('body'). Attached ('<' h1 & gt; News & lt; / h1 & gt; '); $ ('Body') App ('& lt; h2 & gt; main display & lt; / h2 & gt;'); $ ('Body'). Andand ("& lt; div id = 'success_news_main' class = 'waiting'" Waiting for response "); $ .jax ({type: "gET", url: 'http://myurl.com/news.php', datatype: 'jason', username: password, my password, success: work (data) {var ul ($ '' (' & gt; Attr (' id ', k) .HTML (v) .appendTo (ul);});}}); }
You should not use string consonance while creating HTML tags for display . Instead use the jQuery function, create a Dom element, add attribute values for them, and add them to the page.
Here's how to modify your code:
$. Ajax ({Type = 'GET', url: 'http://MyURL.com', Datatype: 'Jason', Username: myusername, password: mypassword, success: function (data) {var ul = $ ('& Lt; ul / adlas ('my-new-list'). Append to ('body'); $ .eee (data.teams, function (k, v) {$ ('& lt; li / & gt;' ). Attr ('id', k) .html (v) .appendTo (ul);});}}); It is also easy to read and twice It does not look like.
In addition, "V" within the "$." Array of objects within the Json you need to reach your personal assets and Necessary HTML / elements will need to be installed directly as HTML property.
Comments
Post a Comment