简体   繁体   中英

Convert Prototype to jQuery when using ajax requests?

I have the following Prototype javascript function:

<script type="text/javascript">
  function go(qry) {
    new Ajax.Request('script.py?q=' + qry,
        {method: 'GET'}
    );
  }
</script>

Is there a way of making this work with jQuery? I'm not sure how to use the jQuery.ajax() method in the context of the original Prototype version.

I've also seen a jQuery.get() method, not too sure which I should be using.

I was wondering if something like the following would be along the right lines?

<script type="text/javascript>
  $.ajax({
function go(qry) {
url: 'doStuff.py?q=' + qry
    );
  });
</script>

Any help would be appreciated!

<script type="text/javascript">
  function go(qry) {
    $.ajax({
      type: "GET",
      url: 'script.py?q=' + qry,
    });
  }
</script>

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