php - How to include ajax post into get form and exclude used inputs by ajax in get url? Laravel -


so have search form (i have written in laravel html, code self explaining; pure html answers welcome too):

{!! form::model($search, ['url' => 'projects/', 'method' => 'get']) !!} //select option want include url {!! form::select('sort', array(0 => 'sort: update date', 1 => 'create date', 2 => 'follows'), null, ['id' => 'sort', 'class' => 'form-control']) !!}  //a has ajax post request b options. , b shouldn't appear in url (exclude , b alone - used create mixed ab combinations).  {!! form::select('a', array(...), null, ['id' => 'a', 'class' => 'form-control']) !!} {!! form::select('b', array(...), null, ['id' => 'b', 'class' => 'form-control']) !!} {!! form::button('add b combination', ['class' => 'form-control']) !!}  //include , b combination url {!! form::select('a_b_combinations[]', array('' => ''), null, ['id' => 'expected', 'class' => 'form-control', 'multiple', 'style' => 'display: none;']) !!}  {!! form::submit('search', ['class' => 'form-control']) !!} {!! form::close() !!} 

i want in url appear sort option , mixed b combinations variable.

my example ajax code:

$( "#a" ).change(function() {     $.ajaxsetup({ headers: { 'x-csrf-token': $('input[name="_token"]').attr('value') } });     $.ajax({       type: "post", /* 'post' works in post form, 'get' doesn't work in form.*/       url: '/ajax/b',       data: {a: a_id},       //success: onsuccess,       datatype: 'json',       success: function( json ) {           $.each(json, function(i, value) {             $("#b").append(                 $("<option></option>")                     .text(value.display_name)                     .val(value.id)             );           });       }     }); }); 

maybe doing wrong, have no idea how one? works fine if use post method, problem want search data appear in url.

the idea come is:

  1. create form required inputs should appear in url bar + hidden input of combined values.
  2. second post form on same page add button , ajax options.
  3. on pressing 'add' -> add combination jquery hidden field in form.

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -