0

i have a controller.js which makes a JSON call to a php file. In the php file i need to see a few values, when I echo it it does not show.

here my code:

//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 
}

when i refresh my page i get a "NO" displayed at the top???

what is the best way to display values when you mix js with php? thanks

1 Answer 1

2

Change:

echo $contentlocation;

to:

echo json_encode($contentlocation);

because $.getJSON requires the script to send JSON.

Sign up to request clarification or add additional context in comments.

4 Comments

i have the echo in the php part and changed it to your suggestion but still nothing on my page except the "NO"
I don't see anything in your code that displays "NO", so I have no idea where that's coming from.
Actually, I don't see where your code displays the data returned from the server. Is that what self.set('content', data) does?
yikes i just started working on this code and also have no idea where the "NO" comes from. wrt the self.set probably. i guess i will have to ask someone here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.