homepage Welcome to WebmasterWorld Guest from 54.237.78.165
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Extracting Values from Javascript for Conversion to Another Language
javascript values
rugrat



 
Msg#: 4430167 posted 12:28 am on Mar 17, 2012 (gmt 0)

Hi everybody. Hoping I'm at the correct dept. i just put a sample page together with scriptaculous coding for sorting list items and though I got the basic script to work it left me at a loss for updating the mysql database with the new values. I did a mega search on the subject and did find a couple examples using php to do this but the problem is I'm using perl. How does one extract the new values out of the javascript code for converting them to perl (so I can move on the the next challenge updating the database)?
I'm totally at a loss with javascript and not all that well versed at perl either but I am beginning a major study on javascript/ajax.

 

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4430167 posted 5:03 am on Mar 17, 2012 (gmt 0)

The same javascript should work for both php and perl.

The results will be returned as part of the GET or preferably POST request. How you extract the results (get or post parameters) on the server will differ.

Change the .php in the url to whatever perl expects.

rugrat



 
Msg#: 4430167 posted 1:20 am on Mar 19, 2012 (gmt 0)

Trial and more error
I'm using the following javascript along with the scriptaculous.js and prototype.js:

<script type="text/javascript">
function updateOrder(){
var options = {
method : 'post',
parameters : Sortable.serialize('firstlist')
};
new Ajax.Request('g2.pl', options);
}
Sortable.create('firstlist', {constraint:'vertical', onUpdate : updateOrder});
</script>

What would be the variable names getting passed through the post method? Seems no matter what I try I can't get the variable values returned.

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4430167 posted 6:13 am on Mar 19, 2012 (gmt 0)

new Ajax.Request('g2.pl', options);

This results in the parameters being sent in the body of the post rather than as part of the url.

So either read the post body on the server or change to

new Ajax.Request('g2.pl?list='+encodeURIComponent(Sortable.serialize('firstlist')), options);

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved