Jump to content

[SOLVED] Need help with an Ajax script, probably simple


bluedaniel

Recommended Posts

Im using an Edit-In-Place script found here: http://24ways.org/2005/edit-in-place-with-ajax

 

(js file here: http://24ways.org/examples/edit-in-place-with-ajax/editinplace.js)

 

It works fine except I need another variable sent to the editing php handle file for database updating purposes.

 

The variable I need is $userid which is defined in the php form page.

 

Summary:

[*]Form page - user.php

[*]Ajax script - posts to useredit.php

[*]Editing handle - updates the database with post variables.

 

Thanks people, Im absolutley new to Ajax really

You claim the AJAX forum is dead and your thread hasn't even been here for 3 hours...

 

I don't see any question in your post, you just claim you need to send a variable but don't specify what you're having trouble with.

how much JS do you know ? See the comments below for a suggested solutions

 

function saveChanges(obj){

var new_content	=  escape($F(obj.id+'_edit'));

obj.innerHTML	= "Saving...";
cleanUp(obj, true);

var success	= function(t){editComplete(t, obj);}
var failure	= function(t){editFailed(t, obj);}

  	var url = 'edit.php';

  	//this variable holds your parameters, the ones being sent to PHP script...
  	//Modify this and you should be good to go...just concatenate the parameters & values you need to this line 
var pars = 'id='+obj.id+'&content='+new_content;     //this line//

var myAjax = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:success, onFailure:failure});

}

ok so

 

php file:  <?php echo sprintf( '<input type="hidden" name="hdnTest" id="hdnTest" value="%s" />', htmlentities( $userid, ENT_QUOTES ) ); ?>

 

javascript file:  var userid = ( document.getElementById( 'hdnTest' ).value ); //get the value

                    var pars = 'id='+obj.id+'&content='+new_content+'&userid='+userid; //send it to the third php page

 

thanks people!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.