...

View Full Version : adding variable to ajax function



mskocabay
09-11-2007, 01:45 PM
function dosyaSil(silinecekDosya) {
if( confirm('Dosya Silinsin mi?') ) {
var sc="yap=sil&dosya="+silinecekDosya;
JXP(1, "dizin_alani", "cevap.php", sc);
}
}

this is my ajax fuction takes filename from
<?php echo '[<a href="javascript:dosyaSil(\''. $res['picture1']. '\');">sil</a>]';?> but i want added $user_id after $res['picture1']
how can i change php code and function dosyasil ?

thanks

A1ien51
09-11-2007, 02:04 PM
what is hard about it?

il(\''. $res['picture1']. '\',\''. $res['foo']. '\');

and

dosyaSil(silinecekDosya,foo)

and

var sc="yap=sil&dosya="+silinecekDosya + "&foo=" + foo;

Eric

mskocabay
09-11-2007, 02:19 PM
what is hard about it?

il(\''. $res['picture1']. '\',\''. $res['foo']. '\');

and

dosyaSil(silinecekDosya,foo)

and

var sc="yap=sil&dosya="+silinecekDosya + "&foo=" + foo;

Eric

i try this but i took javascript error


<?php echo '[<a href="javascript: DosyaSil(\''. $res['picture1']. '\',\''. $res['user_id']. '\');">sil</a>]';?>

<script type="text/javascript">
function dosyaSil(silinecekDosya,user_id) {
if( confirm('Dosya Silinsin mi?') ) {
var sc="yap=sil&dosya="+silinecekDosya + "&user_id=" + user_id;
JXP(1, "dizin_alani", "cevap.php", sc);
}
}

link shortcut seems javascript: DosyaSil('asd.jpg','115');

A1ien51
09-11-2007, 05:22 PM
What does the following output when you do a view source on the webpage.

<?php echo '[<a href="javascript: DosyaSil(\''. $res['picture1']. '\',\''. $res['user_id']. '\');">sil</a>]';?>

What is the JavaScript error?

Do you use Firefox? If you do, you can install the firebug extension [http://www.getfirebug.com] which will make debugging JavaScript easier.

Eric

mskocabay
09-12-2007, 08:35 AM
Error: DosyaSil is not defined
Kaynak dosya: javascript: DosyaSil('asd.jpg','115');
Hat: 1


Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIWebNavigation.loadURI]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: chrome://global/content/viewSource.js :: viewSource :: line 141" data: no]

A1ien51
09-12-2007, 02:58 PM
<?php echo '[<a href="javascript: DosyaSil(\''. $res['picture1']. '\',\''. $res['user_id']. '\');return false;">sil</a>]';?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum