/    Sign up×
Community /Pin to ProfileBookmark

jQuery $.post… better way to see errors?

I am a big fan of print_r(), it lets me dump my arrays and fix accordingly. But when building the php page that will communicate with JS file it always a pain syncing them together because I’m basically coding the php file blind.

Example (what caused me to write this post): I forgot a close bracket in an if() statement, normally that would take me all of 5 seconds to find/fix. But to find the problem I had to fake all my post variables and run the php file directly… I know it’s not much but it adds up FAST.

Does anyone know of a better way? Is there some tweaking that can be done to the JS so that it basically bumps everything the php file returns including errors… dumps…?

Thanks,
-aPeg

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 26.2010 — 
Does anyone know of a better way?[/QUOTE]

Sure. Learn JavaScript and write your own custom codes, suitable exactly on your needs. Or learn JavaScript, so that you will be able to find the limits of a JavaScript library. JQuery is not God, it is just a limited JavaScript library, after all. It is not able to supply the lack of JavaScript programming language knowledge. :rolleyes:

What in fact is your aim? Can you detail it, please?
Copy linkTweet thisAlerts:
@apegauthorMay 26.2010 — Humm now what would be the point of going to a WEB DEVELOPER site if not to better learn how to code?

But your advice is greatly appreciated, I'm glad i spent the time to read it and you spent the time to write it ?

I think i got it from here, thanks Kor
Copy linkTweet thisAlerts:
@KorMay 26.2010 — To see better your JavaScript possible errors use Firefox as a browser:

http://www.mozilla.com/en-US/firefox/personal.html?from=getfirefox

and add its Firebug as an Add-on:

https://addons.mozilla.org/en-US/firefox/addon/1843/
Copy linkTweet thisAlerts:
@criterion9May 26.2010 — I get the impression this question is more geared at troubleshooting the php portion of the application.

I almost always code the PHP independently and create stub forms to post back and forth from to test the PHP sufficiently before I introduce additional possibility for error by using an additional language into the mix.
Copy linkTweet thisAlerts:
@KorMay 26.2010 — I get the impression this question is more geared at troubleshooting the php portion of the application.

I almost always code the PHP independently and create stub forms to post back and forth from to test the PHP sufficiently before I introduce additional possibility for error by using an additional language into the mix.[/QUOTE]

eeer? I don't quite understand. Do you expect JavaScript to handle the PHP errors? No way.

You have var_dump() for that, or echoes, or whichever PHP possibilities... I really don't understand your aim. PHP is a server-side language while JavaScript is a client-side one. No relationship between, except when PHP writes a JavaScript code and when JavaScript force a query to a PHP external file.

Really, what is your question, after all?
Copy linkTweet thisAlerts:
@sohguanhMay 27.2010 — I am a big fan of print_r(), it lets me dump my arrays and fix accordingly. But when building the php page that will communicate with JS file it always a pain syncing them together because I’m basically coding the php file blind.

Example (what caused me to write this post): I forgot a close bracket in an if() statement, normally that would take me all of 5 seconds to find/fix. But to find the problem I had to fake all my post variables and run the php file directly... I know it’s not much but it adds up FAST.

Does anyone know of a better way? Is there some tweaking that can be done to the JS so that it basically bumps everything the php file returns including errors... dumps…?
[/QUOTE]


If you are referring to jQuery AJAX features there is a $.ajaxError method you can call. Refer to http://api.jquery.com/ajaxError/ for some sample code.

You can inside the callback function, explore to see if can use Firefox FireBug console.log method to print so you can view the error output on a small screen for debugging.
×

Success!

Help @apeg spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...