Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

How to Submit AJAX Post onchange

$
0
0

I'm trying to figure out why this isn't working, I don't want to have a submit button to click, It does work if I have one though, instead I use onchange="this.form.submit()" and that posts the form as it normally would. I found it and made it work for my situation, but as far as I know $('#ajaxform').submit(function (), submit is submit? Why isn't onchange="this.form.submit()" and the same type of submit? What am I missing?

<form class="form-inline" id="general-settings" method="POST">
<select name="tTunes_tune_screen_option" id="tTunes_tune_screen_option" class="form-control" onchange="this.form.submit()">
  <option value="tTunex_tune_stream"<?php Global $tTunes_tune_screen_option_val; echo ($tTunes_tune_screen_option_val == 'tTunex_tune_stream') ? 'selected="selected"': '';?>>টিউন স্ট্রিম</option>
  <option value="tTunex_recent_tunes"<?php echo ($tTunes_tune_screen_option_val == 'tTunex_recent_tunes') ? 'selected="selected"': '';?>>Recent টিউনস</option>
</select>
  <input type="hidden" name="hash_id" value="<?php echo PT_CreateSession()?>">
  <input type="hidden" name="user_id" value="{{ME id}}">                                                
</form>

//script

<script>
     $(function() {
        var form = $('form#general-settings');
        form.ajaxForm({
            url: 'http://localhost/aj/user/general?hash=' + $('.main_session').val(),
        });
    });
</script>

//ajax_code_in_another_file

if ($first == 'general') {
   $user_data = PT_UserData($_POST['user_id']);
   $tTunes_tune_screen_option = PT_Secure($_POST['tTunes_tune_screen_option']);
   $update_data = array(
       'tTunes_tune_screen_option' => $tTunes_tune_screen_option,
    )
}

Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>