Jquery mobile json from php
Jquery mobile json from php
am以json 的形式从php获取数据
代码:
I have added json_encode() to the php database output
JQUERY MOBILE:
$.getJSON('custom/php/showresults.php',
function(data){
console.log(data)
}
console.log(数据)输出为:
{'name':'Geowan', 'surname':'hiu'}.
如何将其更改为以对象方式输出,以便使用data.name
您想直接访问数据吗?
$.getJSON('custom/php/showresults.php',
function(data){
console.log(data.name)
}
如果您希望它将其分配给变量
var jsonData = $.getJSON('custom/php/showresults.php',
function(data){
return data;
}
if(jsonData){
console.log(jsonData.whatever)
}
或简称
$.getJSON('custom/php/showresults.php',function(data){
return data.whatever;
}
相关文章:
- 如何计算与php中的CRC32函数兼容的arrayBuffer(javascript中的From FileReader)
- fetch data from db using javascript & php
- Jquery mobile json from php
- PHP readImageBlob from SVG
- Get latlng from different addresses using PHP & JavaScri
- Returning JS from PHP
- PHP bringing in XML from URL
- Unable to receive something in PHP from XMLHttpRequest's
- Javascript getElementById from php foreach loop
- window.open from PHP script
- running javascript from php?
- If Else Condition with Ajax responseText from PHP
- Calling PHP from document.ready
- From php json_encode to jquery decode
- Regex - From PHP to JS
- Execute php url from jscript
- javascript中是否有类似于compact from php的函数?
- Passing specific value via POST from <img> to PHP
- Javascript from PHP (wordpress)
- Call php from javascript