• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

AJAX requests returning Javascript calls

Jonz

Weaksauce
Joined
Apr 16, 2006
Messages
84
Hey guys,

well it seems I have messed up a bit with the development of an AJAX app. I figured it wouldn't be a problem in including Javascript calls in the echo'd requests to my PHP pages. It works great on the home .html page, but is a bigtime no-go on anything else.

So, it seems I'm faced with having to decide between the following approaches.

1) Recode the results into XML, and use eval() to run the javascript part ** Time Consuming to recode and learn this method... any suggestions if I were to take this route? **

or

2) Create a popup window (without using javascript...), or lead the user to another URL, that runs my Javascript stuff that allows for more seamless entry of data... though not using the popup method kind of defeats the point of using it at all.

or

3) Stick with forms and just style the hell out of them


I'm most interested in option #2 - just have the results link to a similar php page that passes the data along, opens in a new window, allows the user to edit the results, then closes the window and updates the database.

Any ideas? Thanks!
 
If I understand your issue, you can use jQuery's getScript to get javascript code and execute it on the fly. I have lots of PHP scripts that generate customized javascript and I use getScript to run it dynamically.
 
1. If you use XML, you're never going to need to use eval(), I've been programming in JavaScript since Netscape 3 was popular, I rarely ever use eval(). Read AJAX/Javascript XML Processing Example/Tutorial.
2. Pop-up windows make you fucking die, next time you think about using a pop-up, check the calendar, if it isn't 1998, don't use a pop-up window.
3. If you want.

Per RendereR's suggestion: If you don't know javascript, don't use jQuery/prototype/dojo. Learn how to do DOM scripting the normal way, before you get into a framework. If you don't learn the proper ways of doing stuff, you'll get lost in the frameworks.

Have you looked into JSON (JavaScript Object Notation) at all? I pretty much only use JSON for AJAX work, these days.
PHP: http://us.php.net/json

If you need help with JSON, feel free to ask, you can message me via AIM, my screen name is the same as my forum name.
 
Ah, perhaps I should have been more clear vbrtrmn.

The main problem is that Scriptaculous InPlaceEdit flatout refuses to work when it is delivered via AJAX scripting... I don't know why -- if the page is called with the GET values included in the URL it works, but when called through AJAX it doesn't. I only mentioned eval() because I read something about some sort of work-around to get javascript to work in this manner

And yes... I do know DOM and javascript, it's just that this framework is being a pain in the arse...

#2 -- yeah I know, it was just a thought (popups, that is)... though in reality I don't think i'd be able to sleep at night if I used that solution :D
 
Glad you already know how to use javascript, I post a lot of help on the DevShed forums, where noobs are trying to use frameworks and wondering why they are having problems. If you're using scriptaculous, you're using prototype, which I am extremely familiar with.

Can you post a snipet of the code you're having problems with or PM me a link to it, I'll be happy to check it out for you.
 
Back
Top