Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    adding variable to ajax function

    Code:
    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
    Code:
    <?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

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    what is hard about it?

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

    and

    dosyaSil(silinecekDosya,foo)

    and

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

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • Users who have thanked A1ien51 for this post:

    mskocabay (09-11-2007)

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by A1ien51 View Post
    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

    Code:
    <?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');
    Last edited by mskocabay; 09-11-2007 at 03:24 PM.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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]

  • #6
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    <?php echo '[<a href="javascript: DosyaSil(\''. $res['picture1']. '\',\''. $res['user_id']. '\');return false;">sil</a>]';?>
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •