jquery - Assign Ajax response to php variable -


how assign ajax response php variable, if possible?

in laravel controller have method purpose:

public function editproductpost(request $request) {     return response()->json([         'slidervalue' => $request->get('value')     ]); } 

and ajax:

    /**      * ajax post      */     $.ajaxsetup({         headers: {             'x-csrf-token': $('meta[name="csrf-token"]').attr('content')         }     });      $.ajax({         type: 'post',         contenttype: "application/json",         url: "{{ route('editproductpost', $product->id) }}",         headers: {             'x-requested-with': 'xmlhttprequest'         },         data: json.stringify({              value: getsliderval,             productid : getprid         }),         datatype: 'json',         success: function(response) {             // response             console.log(response.slidervalue)         } 

if understand correctly, want this:

public function editproductpost(request $request) {     // create json response     $response = response()->json([         'slidervalue' => $request->get('value')     ]);      // assign content of response variable     $responsecontent = $response->content();      // return response     return $response; } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -