0

i have a form and need to send values of textboxes to php side.

I always put my variable's value to a hidden and then send it to php side. I think this is foolish. Is there a way to send textbox values like that

$.post("adasda", {"degisken1":$("#txtEmail").val()} ,function(response){})
1
  • The code you have should work fine, assuming adasda is a valid path in your web app. Is there a specific problem you're having? Commented Apr 18, 2012 at 12:43

1 Answer 1

3

Yes, you can send the textbox values through jquery ajax , post or get method. Below is a sample example

$("#searchForm").submit(function(event) {
    /* stop form from submitting normally */
    event.preventDefault(); 

    /* get some values from elements on the page: */
    var $form = $( this ),
        term = $form.find( 'input[name="s"]' ).val(),
        url = $form.attr( 'action' );

    /* Send the data using post and and get the results */
    $.post( url, { s: term },
        function( data ) {
            // write your code here
        }
    );
});

Details see here http://api.jquery.com/jQuery.post/

Thanks

Sign up to request clarification or add additional context in comments.

2 Comments

$.post('/json/management/updateAllAjax', { "name": $("#IDname").val() ,"orgName" : $("#IDOrg").val() }, function(response){ alert(response); }); alert($("#IDname").val()) gives value but i cannot send this to php side
See my above example is sending the value 'term' with the 's' variable and this goes to the action url. Or better you can get those values in certain variables before writing the post method and alert them. Then try to send those variables through post method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.