|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I am using (or attempting to use, anyway) an AJAX solution for use in posting client-side information to update database values on my website. I have the AJAX portion working and calling a page to process the database update, but I'm having problems getting the values from the client-side javascript to use in my local AJAX javascript function.
For instance, I run website www.aaa.com, and within my site, there is a call to a javascript at an external website, bbb.com which I use to display certain information within my site. So, I call bbb.com's javascript as such: Code:
<script type="text/javascript"
src="http://www.bbb.com/jsfunction.js?a=30&key=deadbeef"></script>
Something like: Code:
<script type="text/javascript">
var key = "<?= $item_key ?>";
var xyz = document.write("<script type='text/javascript'
src='http://www.bbb.com/jsfunction.js?a=30&key="'+key+'"><\/script>');
ajaxFunction('update', xyz);
</script>
Thanks.
__________________
Rick - Linux Tutorials for Beginners allin-enterprises.com | VaGunForum.net | all-in-general.com | MagliteSales.com | Last edited by krnl; 11-12-2007 at 08:46 PM. |
|
||||
|
What makes this AJAX? Where is the asynchronous communication with the server? A time now since I looked at AJAX, but can you use the XMLHttpRequest Object that is used for asynchronous communication with the server?
Also note that DOM is intimately integrated with the X (XML) part of AJAX. Very much can be done with DOM functions and more specifically with DOM XML functions. No need to reinvent the wheel.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 11-13-2007 at 12:19 PM. |
|
|||
|
The ajax function is defined earlier in the file and uses the xmlhttprequest mechanism to call a local php script that will take care of the database update. The call to the ajax function follows the javascript stuff with ajaxFunction('update', var1, var2); where var1 is the key and var2 is the output from the remote javascript call.
Code:
function ajaxFunction(action,var1,var2) {
http.open('get', 'rpc.php?action='+action+'&var1='+var1+'&var2='+var2);
http.onreadystatechange = handleResponse;
http.send(null);
}
If I'm reinventing the wheel and going about this all wrong, then please tell me what the proper approach is. Thanks for your feedback! I look forward to hearing more!
__________________
Rick - Linux Tutorials for Beginners allin-enterprises.com | VaGunForum.net | all-in-general.com | MagliteSales.com | |
|
||||
|
As I told you, I am a bit away from AJAX now, but note that Google combines Remote Scripting with IFRAME with the XMLHttpRequest object as far as I know to get the best combination of both worlds.
I am not sure that that solves your problem though, and I can not, as I told be more specific now. Will take me some hours to repeat that stuff. |
|
|||
|
kgun, I do appreciate your input. I'll keep reading with a couple of the links that are provided in your post.
If anyone else has any thoughts on how to accomplish my objective, please let me know! Thanks!
__________________
Rick - Linux Tutorials for Beginners allin-enterprises.com | VaGunForum.net | all-in-general.com | MagliteSales.com | |
|
||||
|
I know where I would have looked. In one of the following to books that I have here:
|
|
|||
|
[url="http://www.devshed.com/c/a/Security/A-Quick-Look-at-Cross-Site-Scripting/1/"] A Quick Look at Cross Site Scripting - What is Cross Site Scripting?[/ur]
BTW, there is a way to serve php with ajax, but I havent found it yet, but for now, this site is excellent, here are some: [url="http://www.devshed.com/c/a/PHP/Creating-AJAX-Requester-Objects-with-Abstract-Factory-Classes-in-PHP-5/"]Creating AJAX Requester Objects with Abstract Factory Classes in PHP 5 [/ur] [url="http://www.devshed.com/c/a/PHP/PHP-Datastorage-Class/1/"] PHP Datastorage Class[/ur] Before we get into the nitty-gritty of XML parsing with PHP, I'd like to take some time to explain how all the pieces fit together. [url="http://www.devshed.com/c/a/XML/Using-PHP-with-XML-part-1/1/"]Using PHP with XML [/ur] [url="http://www.devshed.com/c/a/PHP/PHP-and-JavaScript-Interaction-Storing-Data-in-the-Client-part-1/"]PHP and JavaScript Interaction: Storing Data in the Client [/ur] [url="http://www.devshed.com/c/a/PHP/Creating-AJAX-Requester-Objects-with-Abstract-Factory-Classes-in-PHP-5/1/"] Creating AJAX Requester Objects with Abstract Factory Classes in PHP 5 - Working with AJAX HTTP requester objects[/ur] This guy is excellent, I mean excellent. Ho has a tute on serving php dynamically with javascript, etc.. [url="http://www.devshed.com/cp/bio/Alejandro-Gervasio/"]Alejandro Gervasio [/ur] but I cannot find them. I have on my back-ups somewhere, and will get. I also used PEARL libraries to do what you want to do. I have been out for two years, but I know it has been done, don't need to re-invent! I did it with ajax and xml as well as MySQL db when dooing google maps programming. Basically, you can put ajax into a <div> and read and write there dynamically without re=generating your whole page. More specifically, in this second article of the series, I'm going to demonstrate how to apply the abstract factory pattern to create diverse AJAX HTTP requester objects, which can be used in distinct contexts. [url="http://www.devshed.com/c/a/PHP/Creating-AJAX-Requester-Objects-with-Abstract-Factory-Classes-in-PHP-5/"]Creating AJAX Requester Objects with Abstract Factory Classes in PHP 5 [/ur] I'll be back later with a staright forward solution... Basically parsing js and extracting the var, then using echo to write the js withthe var included. (WTF?) Last edited by mikmik; 11-15-2007 at 06:34 PM. |
|
||||
|
"Cross server scripting", a potential security risk or am I wrong when done by the webmaster him/her self?
zXml 1.0.2 A JavaScript library for cross-browser XML, XPath, and XSLT support. (24 KB) One of the best JS libraries for AJAX I know off. There are other on the page: NCZOnline - Downloads
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 11-16-2007 at 11:06 AM. |
|
|||
|
Quote:
I haven't had a chance to work on this for the last couple of days, but I do appreciate the replies that I have received and will be visiting them for information when I get back into this.
__________________
Rick - Linux Tutorials for Beginners allin-enterprises.com | VaGunForum.net | all-in-general.com | MagliteSales.com | |
|
||||
|
Quote:
May be Davey Shafik, Ligaya Turmelle, Harry Fuecks, Matthew Weier O'Phinney & Ben Balbo (2007) "The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition" that I have just ordered is the updated version. As you can see, there is also a code archive with that book that you get access to once you have bought the book. I think there is a database class there that eases the connection to more than one database at the same time. If I remeber correct, it is explained how you can access MySQL in one part of your application and another database like PostgreSQL: The world's most advanced open source database in another part of the application.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 11-16-2007 at 12:36 PM. |
|
|||
|
Quote:
I don't like this any more, and I wont help you. What kind of script queries a DB? I am curious about this, because you need a server-side language, not a scripted language, to make a DB connection. This is fishy. (asp not included, <-_0> Last edited by mikmik; 11-18-2007 at 02:58 AM. |
|
|||
|
Perhaps I misspoke. The database query is performed by an ASP page (I know nothing about ASP...I'm a PHP kinda guy). The output of the query is provided to subscribers of the service via this remote javascript function.
You can call it fishy all you want. I think I'm giving up on this approach anyway. The developer on the other site is trying to whip up something that's a little more user-friendly on subscriber side of things. Thanks for all the great input everyone. Onward and upward...
__________________
Rick - Linux Tutorials for Beginners allin-enterprises.com | VaGunForum.net | all-in-general.com | MagliteSales.com | |
|
||||
|
There are ASP to PHP translators and PHP to ASP as well.
<? PHP CODE in ASP ?> - IIS.net Note the date of the post. There may be better updated solutions, and the right place to ask should be the Forums - IIS.net PHP4Mono Kw search Exact: "php to asp translation" Free: php to asp translation Other: php to asp compiler php to asp processor It is not an ideal solution, but it is one fast ad hoc solution if it can be used. If you buy the book I mentioned above, I think the name of the connection class (where the database connection is encapsulated - $db=& new MySQL($host,$dbUser,$dbPass,$dbName); ) is MySQL included in the file MySQL.PHP that followed with the code archive to the old books (volume I and II). Old version of MySQL.php used (Is there a more up to date version in the new book?) OOP in PHP and MySQL tips: Start here. Some of the links may be broken since I moved the code to a server with PHP 5.2.* and have had no time to update it. Note: PHP 5.2.5 Released For some PHP projects, like XML parsing you may need that version.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 11-18-2007 at 11:29 AM. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [For Hire] Expert in Php, Mysql, AJAX, JavaScript, HTML, XML, Smarty , API | shailesh.gajjar | Services for Sale/Hire | 0 | 07-13-2007 02:59 AM |
| Javascript + RSS + RSS = ? | ofoglada | Web Programming Discussion Forum | 6 | 02-05-2006 06:33 AM |
| JavaScript Remote Scripting: Building an AJAX-based Random | WPW_Feedbot | Graphics & Design Discussion Forum | 0 | 10-20-2005 02:31 PM |
| XP SP2, IE and Javascript | ChrisBowd | Graphics & Design Discussion Forum | 1 | 08-26-2004 08:23 AM |
| Javascript PC vs MAC | epern | Graphics & Design Discussion Forum | 8 | 04-03-2004 04:26 AM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |