混合使用php和javascript时显示值的最佳方式

混合使用php和javascript时显示值的最佳方式,javascript,php,Javascript,Php,我有一个controller.js,它对php文件进行JSON调用。在php文件中,我需要看到一些值,当我回显它时,它不会显示 这是我的代码: //Controller.js show: function(data) { var self = this, salesquoteguid = data && data.salesquoteguid || self.salesquoteguid; $.getJSON('data/load.salesquote.php', {sales

我有一个controller.js,它对php文件进行JSON调用。在php文件中,我需要看到一些值,当我回显它时,它不会显示

这是我的代码:

//Controller.js
show: function(data) {
var self = this,
salesquoteguid = data && data.salesquoteguid || self.salesquoteguid;

$.getJSON('data/load.salesquote.php', {salesquoteguid: salesquoteguid}, function(data) {
self.set('salesquoteguid', salesquoteguid);
self.set('content', data);
self.set('pricemethod', data.pricemethod);
self.set('salesquoteitems', data.salesquoteitems);
    });
},

//data/load.salesquote.php
function getSalesquoteitemRecords(//some parameter)
{
   if ($contentlocation = App::getContentLocation()) {
     $contentlocation.= 'images/item/';
 $targetDirExists = PATH_CLEVVA.$contentlocation;
 $targetDir = PATH_CLEVVA_DISPLAY.$contentlocation;
}
   echo $contentlocation;  // I need to see this value 
}
当我刷新我的页面时,我会在顶部显示“否”

当您将js与php混合使用时,显示值的最佳方式是什么? 感谢更改:

echo $contentlocation;
致:


因为
$.getJSON
需要脚本来发送JSON。

我在php部分有回音,并将其更改为您的建议,但我的页面上除了“否”之外仍然没有任何内容,我在您的代码中没有看到任何显示“否”的内容,因此我不知道这是从何而来的。实际上,我看不出您的代码在哪里显示从服务器返回的数据。这就是
self.set('content',data)
的功能吗?我刚刚开始编写这段代码,也不知道“no”是从哪里来的。可能是自拍。我想我得问问这里的人。
echo json_encode($contentlocation);