0

I have a script (editablegrid) that loads an php file (loaddata.php) inside a js file(JSON)(demo.js). When i make a js alert on php file:

echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';

Script stopped and alert it's not show. If i remove this echo's script works fine. How can i make an alert to see a var (an $sql var)?

Thanks

2
  • According to your demo url, you are loading it like this : this.editableGrid.loadJSON(url); ? If yes, try to load it using different way since the data is supposed to be json Commented Mar 7, 2015 at 17:32
  • I can do with XML, but with loadXML, i can't do any echo on loaddata.php neither Commented Mar 8, 2015 at 16:54

2 Answers 2

1

I suspect that you are echoing inside an already opened <script> tag.

Try removing echo '<script language="javascript">'; and echo '</script>'.

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

5 Comments

No, it doesnt works. If i write only echo someting script stop and not show data. If i remove this echo data is showed well. And i need to write echo for debug a var. Thanks
Probably the console is throwing some info that will help us know what is going on. Press F12, select the console and paste here what it is showing.
Here it's error SyntaxError: missing ) in parenthetical (test{"metadata":[{"name":"post_title","label":"Cliente","datatyp. Test it's a echo
Looks like the JSON data is badly formatted. Probably the closing ) is missing.
But this error it's only when i make an "echo ,,,,". I think that when encode JSON, it's encoded badly and shows this error. But i don't know how can i do it
0

To debug I use the following to save data from php into javascript. Flavor to your liking:

<?php
$aTmp[ 'data1' ] = 'coolstuff1!';
$aTmp[ 'data2' ] = 'coolstuff2!';
echo '<script>';
echo "var oData = [];";
echo 'var oData = ' . json_encode( $aTmp ) . ';';
echo 'console.log( oData );';
echo '</script>';
?>

11 Comments

If i paste this code, script stopped and message it's not show. I don't know why. If i put a simple echo "Hello", script don't run
Use browser's console to inspect data. Right click open console and you'll see the data under logging section. Check out firebug! addons.mozilla.org/en-us/firefox/addon/firebug
I can't see on Firebug. Look gestoriabarcelona.com/gestion/demo/…
Can anyone install editablegrid an test how to make a debug inside loaddata.php file?
I see a syntax error on firefox: Right click, Inspect Element, SyntaxError: expected expression, got '<' Can you post the file you're running? I edit my original post to include php tags you may have been missing.
|

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.