Reputation: 21
I'm trying to change a prototype function in an application over to jQuery.. The old application was built using Prototype, but the new one already requires jQuery, and naturally prototype and jquery are conflicting. Rather than using just the noConflict class, and loading the entire prototype library for one function, I think it'd be better rewrite the function to use jQuery.
I can't modify the rest of the application, I need the result to be the same when ajax_call is returned, using just jQuery. I'm new to jQuery and getting caught up in the syntax. Thank you in advance for your help.
<script>
function ajax_call(urlValue){
if(urlValue == null){
urlValue = '<?=MAINURL?>/ajaxWork.php';
}
new Ajax.Request(urlValue,
{
method:'post',
parameters: $('enter_form').serialize(true),
onSuccess: function(transport){
var response = transport.responseJSON;
<? echo (!$debug) ? "//" : ""; ?>var text = transport.responseText;
<? echo (!$debug) ? "//" : ""; ?>$('testarea').value = text;
for (var k in response){
$(k).value = response[k];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
};
</script>
Upvotes: 1
Views: 52
Reputation: 3067
You could try using the .ajax() call, it should be able to handle your params. Check out this page.
http://api.jquery.com/jQuery.ajax/
Upvotes: 1