简体   繁体   中英

How to get params sent by JQuery.load

i want to send parameters by $().load.

I tried this, to send:

 $('#result').load('form.html', {'doc_id': '12'}); 

On form.html i try to read the doc_id via this function:

 function getUrlVars() { alert ('Drin in getURL'); var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); alert ('Hashes:' + hashes); for (var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } 

But this doesn't work. I think the reason is that the URL does not change when using the JQuery.load() function. The function getUrlVars is trying to read out doc_ic from URL but since the URL does not change, it fails. So how do i get doc_ic in form.html?

Best regards Daniel

Looks like this form {'doc_id': '12'} makes POST request. You can try these variants:

1) $('#result').load('form.html', 'doc_id=12');

2) $('#result').load('form.html?doc_id=12');

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