 |
 | Javascript + Php - error message |  |
 |
 | |  |
Joined: 18 Sep 2007 |
Posts: 54 |
Location: Croatia |
|
 |
Posted: Thu Oct 08, 2009 3:57 am |
|
 |
 |
 |
 |
Since there is now 'Problems' tab in PhpEd this JavaScript error log problem is even bigger.
Here is piece of code:
changeReminder(<?php echo (int)$session->page_permission ?>, '<?php echo $session->lang_array['save_reminder_message'] ?>', true);
|
There shouldn't be any problems at all, but IDE is returning error on every comma and ;
Since my pages are full of JavaScripts, I'm getting a lot of errors and I can't concentrate on real one.
Please do something about it, or at least tell me how to disable this function for JS in IDE as it is consuming resources but not working well.
|
|
 |
 | |  |
Joined: 10 Oct 2009 |
Posts: 1 |
|
|
 |
Posted: Fri Oct 09, 2009 3:33 pm |
|
 |
 |
 |
 |
Loading Errors:
These are the equivalent of compile errors in languages such as C++ and Java. Since JavaScript code is an interpreted language, even the most prominent errors won't be caught until the script is loaded in a browser. This type of error, which has the grave effect of halting script execution immediately, can usually be spotted by an error message that refers to some kind of incorrect syntax, such as a missing brace or function parentheses.
Runtime Errors:
The second type of error occurs when the JavaScript interpreter comes across some code that it can't understand. Again, syntax errors, such as misspelled variable names, may be the culprit. Illegal assignments, such as to the this pointer, will also cause a runtime error.
Logic Errors:
Errors in processing logic, which can result from misunderstanding the requirements to not drinking enough coffee, are what lead to what developers affectionately refer to as "bugs". A bug can manifest itself as a JavaScript error in any number of ways. Suppose that you wrote a process that expects JSON-formatted data to be returned from the server. Unbeknownst to you, the owner of that application transfers data in XML format. You had better have some thorough error handling in place, or be ready for some strange behavior!
|
|
 |
 | |  |
 |
 | |  |
 |
 | |  |
Site Admin
Joined: 13 Jul 2003 |
Posts: 8351 |
|
|
 |
Posted: Sat Oct 31, 2009 5:33 pm |
|
 |
 |
 |
 |
Quote: | Yep, problem still exists in 5919.
It shows it's ugly head both in file and in Problems window |
This is not a bug at all. It works as intended.
IDE can't capture any valid js code from your script without executing it, but execution is not what you want, I guess.
Without executing php, your code looks like
PromotionLimit = ;
if ( count + > PromotionLimit && PromotionLimit < 0 )
I can think of two possible solutions:
1) Stop usisng code mixture. Either JS or PHP. Don't use them together. It would improve everything, including code maintainability, and performance. With php code in, your js files can not be cached at the client side, so they will be re-requested for all pages referring to the script.
2) Do not share any single statement between the languages. Either all the statement in php or in js.
For example you can write
<? echo "PromotionLimit = $PromotionLimit" ?>;
instead of
PromotionLimit = <?=$PromotionLimit?>;
|
_________________ The PHP IDE team
|
 |
 | |  |
Joined: 18 Sep 2007 |
Posts: 54 |
Location: Croatia |
|
 |
Posted: Sun Nov 01, 2009 6:54 am |
|
 |
 |
 |
 |
So, if it's not bug, than it's a feature. Just kidding
Anyway thnx for explaining all this Dimitri, it is a valuable insight how things should be setup in PhpEd.
I liked this last option as it will not violate code and maintain dynamic setup of JS vars, what was main point from the start.
But I still think that this will continue to be somewhat problem, as many times these days, JS is getting all variables directly from php.
|
|
Joined: 18 Sep 2007 |
Posts: 54 |
Location: Croatia |
|
 |
Posted: Sun Nov 01, 2009 7:43 am |
|
 |
 |
 |
 |
OK, so I've managed to clear JS errors, but what about CSS errors?
Do I have to live with errors in:
filter:progid:DXImageTransform.Microsoft.Shadow(color='CCCCCC', Direction=135, Strength=2);
|
and
filter:alpha(opacity=10);
|
or can I fix these as well?
|
|
 |
 | |  |
 |
 | |  |
Veteran
Joined: 06 Jun 2007 |
Posts: 289 |
Location: Vancouver, Canada |
|
 |
Posted: Fri Nov 06, 2009 2:17 pm |
|
 |
 |
 |
 |
dmitri wrote: | 1) Stop usisng code mixture. Either JS or PHP. Don't use them together. It would improve everything, including code maintainability, and performance. With php code in, your js files can not be cached at the client side, so they will be re-requested for all pages referring to the script. |
There are cases where I want adjust the JS to a particular situation, and mixing in PHP code is very convenient. I understand that this is a complex issue Dmitri, but I am "sure" you can find a way around this, e.g. ignore <?php ?> tags when evaluating JS.
dmitri wrote: | 2) Do not share any single statement between the languages. Either all the statement in php or in js.
For example you can write
<? echo "PromotionLimit = $PromotionLimit" ?>;
instead of
PromotionLimit = <?=$PromotionLimit?>; |
Thank you, this seems a workable solution for now. I still have a strong preference to continue doing it the way MacVato has it in the first post.
|
_________________

|
 |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 1
|
|
|
|  |