title: How to write url in ajax in laravel?
body: <p>I want to call <strong>storeProduct</strong> controller method in ajax URL.    </p>
  
  <p>url: './product_catalog/storeProduct'   </p>
  
  <p>How to call a method in this URL?    </p>
  
  <p>I want to store product_id and campaign id in the database.   </p>
  
  <p>Page not found error occurs.</p>
  
  <p>Route : </p>
  
  <pre><code>Route::get('product_catalog','front\ProductCatalogController@showProductCatalogForm');
  
  Route::post('product_catalog',['as' =&gt; 'storeProduct', 'uses' =&gt; 'front\ProductCatalogController@storeProduct']);
  </code></pre>
  
  <p>Ajax :   </p>
  
  <pre><code>$(".my_form").submit(function(event) {
      event.preventDefault(); //prevent default action 
      var product_id = $(this).find('#product_id').val();
      var campaign_id = $(this).find('#campaign_id').val();
      console.log(product_id);
      console.log(campaign_id);
      $.ajax({
          type: "POST",
          url: './product_catalog/storeProduct',
          data: {
              'product_id': product_id,
              'campaign_id': campaign_id
          },
          success: function(data) {
              alert(data);
              console.log(data);
          }
      });
  });
  </code></pre>
  
  <p>Controller :   </p>
  
  <pre><code>public function showProductCatalogForm()
      {
          //if($_GET["campaign"]!=="") 
              $campaign=$_GET["campaign"];
  
          return view('front.product_catalog');
      }
  
      public function storeProduct(Request $request)
      {
  
          $this-&gt;validate($request, $this-&gt;rules);
  
          $input=Input::all();
          $campaign_product=ProductCatalog::create($input);
          return redirect('product_catalog');
      }
  </code></pre>