<commit_before>$(document).ready(function(){
  submitSearch();
}); 

var submitSearch = function(){
  $("#product-search").on('submit', function(event){
    event.preventDefault();

   var request = $.ajax({
    url:"http://localhost:3000/products/results",
    data: $(this).serialize(), 
    crossDomain: true,
    type:"GET"
   });

   request.done(function(data){
    console.log(data);
    console.log("successssssss");
    $("#product-search").hide();
    $(".search-results").prepend(data);
   });
   request.fail(function(data){
    console.log("fail");
   });
  });
};

<commit_msg>modify js file for the api to display newest items<commit_after>$(document).ready(function(){
  hardLanding();
  submitSearch()
}); 



var hardLanding = function(){
  $('a').on('click', function(event){
    event.preventDefault();

  $('a').remove();
  $(".search-product-form").css("display", "block");
  });
};


var submitSearch = function(){
  $("#product-search").on('submit', function(event){
    event.preventDefault();

   var request = $.ajax({
    url:"http://localhost:3000/products/results",
    data: $(this).serialize(), 
    crossDomain: true,
    type:"GET"
   });

   request.done(function(data){
    debugger
    console.log("successssssss");

    var products = data["products"]


    for(i = 0; i < products.length; i++){
      $(".search-results").prepend("<div class='product'><a href='" + products[i].clickUrl + "'>" + "<img src='" + products[i].image.sizes.IPhoneSmall.url + "' alt='product Image'>" + "</a></div>")
    };

   });

   request.fail(function(data){
    console.log("fail");
   });
  });
};


{'fraction_non_alphanumeric': 0.22441430332922319, 'fraction_numerical': 0.005548705302096177, 'mean_word_length': 3.7595307917888565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817097', 'n_tokens_mistral': 529, 'n_tokens_neox': 511, 'n_words': 83}