Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-26-2012, 04:21 PM   PM User | #1
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
Pass an attribute from JQuery to PHP (on event)?

Hello, first I want to point that I'm using jQWidgets.
I want to pass an attribute from jquery to a PHP file. Now, I've tried using $.post.
Like this:

Code:
$('#problemiTree').bind('select', function (event) {
                    var item3 = $('#problemiTree').jqxTree('getSelectedItem');
                    if (item3 && item3.parentId!=0)
                        dataAdapter4.dataBind();
                    $.post( 
                    "problemiOblastData.php",
                    { selectedItem: item3.label }
                    

                );
In the PHP file I test with:

Code:
if (isset($_GET['selectedItem:']))
    echo 'no';
else
    echo 'yes';
And it always gives "no".

Please help,
thank you.
branko7171 is offline   Reply With Quote
Old 10-27-2012, 03:15 AM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
well no one else answered so I took a look. Looks to me like $('#problemiTree').jqxTree('getSelectedItem'); returns an array, and I'm pretty sure .label only works on form elements, so maybeyou jsut need to remove the .label?
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 10-27-2012, 09:56 AM   PM User | #3
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
I've tried that and I have modified the code in php like so (it was not correct):
Code:
if (isset($_POST['selectedItem']))
    echo 'yes';
else
    echo 'no';
My problem remains ('no' again), but thanks anyway.

EDIT: Maybe I'm not testing correctly. I use a direct link to the php file to check echo.
I've tried using $.ajax, but the result is the same. Is there maybe another way for me to pass data to php?

Last edited by branko7171; 10-27-2012 at 10:44 AM..
branko7171 is offline   Reply With Quote
Old 10-28-2012, 04:20 PM   PM User | #4
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
SOLVED
I've figured out what was the problem. I passed item.label (or item), where I should have passed item.id. mySQL query in the php file requires that id, and it won't work with label etc...
branko7171 is offline   Reply With Quote
Reply

Bookmarks

Tags
php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:23 PM.


Advertisement
Log in to turn off these ads.