0

Does anyone know if I can use a different method of calling the page other than:

window.location.replace("step2.php?cat="+index+"&state="+current_state);

I really want to do a form submit, preferably using jQuery, eg:

javascript:document.ctl.H05.value='311';
document.ctl.cat="+index+";
document.ctl.state="+current_state”;
document.ctl.submit();

Do you know what the syntax would be for that?

2 Answers 2

1

I don't see any jQuery in there. And I think you're looking for ajax; you can check out the MDC doc page for ajax. jQuery has a bunch of ajax related functions. Without more context about your application, the jQuery code to do an ajax request would be:

$.ajax({
    url: 'step2.php',
    data: {cat: index, state: current_state}
});

You could also make a form submit event handler - this way when you click a submit button, the request can be made without the page refreshing:

$('#ctl').submit(function(){
      $.ajax({
        url: 'step2.php',
        data: {cat: index, state: current_state}
    });

    return false; //cancel default form submit action
});

There's also a jQuery plugin to ajaxify form submissions.

Sign up to request clarification or add additional context in comments.

Comments

0

There is a QueryString plugin for JQuery: http://plugins.jquery.com/project/query-object which lets you access/modify querystring in an easy way such as

var newUrl = $.query.set("cat", index).set("state", current_state).toString();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.