简体   繁体   中英

How can I redirect to a page after sending a JQuery get request in rails

I currently am trying to post a simple GET request from a search page and redirect to another page (a product page). However, when I send the request, nothing happens and the page does not change.

My code is below:

javascript

$('.imageBox').click(function () {

        $.get("/s/product/ref", {
            se: search,
            pr: price,
            crr: current,
            bs: best,
            bt: better,
            gd: good
        })
    })
}

main_controller.rb

def product
    respond_to do |format|
      format.js { render :json => @json_data }
    end
    @search = params[:se]
end

I don't see code to direct the user to a different page. Try using window.location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM