Comments (7)
Would it be possible for you to share some sample HTML? One gotcha that's bitten me more than once is not having unique input names between forms. Chibi sends them all but servers expect unique fields, take the value of last unique.
from chibi.
The two forms, similar with the addition of a textarea on the ask a question form. The input "id" were for using chibi .val() to build a data string when I used vanilla js ajax previously (have always had a hard time getting your ajax to work ;-)
<form name="mlist" id="mlist" action="https://www.mydomain.com/send.php" method="post">
<input type="hidden" name="webpage2" id="mlwebpg" value="index">
<input type="hidden" name="form2" value="mlist">
<input type="hidden" name="subject2" id="mlsubject" value="Newsletter Sign Up">
<input type="text" name="name2" id="mlname" placeholder="Your Name">
<input type="email" name="email2" id="mlemail" placeholder="Your Email">
<input type="submit" class="btnmd btnwht" id="mlist2" value="Sign Me Up">
</form>
<form name="asktom" id="asktom" action="https://www.mydomain.com/send.php" method="post">
<input type="hidden" name="webpage" id="hdwebpg" value="index">
<input type="hidden" name="form" value="headqstn">
<input type="hidden" name="subject" id="hdsubject" value="Ask Tom a Question">
<textarea name="message" id="hdmessage" style="height:145px;" placeholder="Hey Tom, I have a question about..."></textarea>
<input name="name" id="hdname" required="required" type="text" placeholder="Your Name">
<input name="email" id="hdemail" required="required" type="email" placeholder="Your Email">
<input type="submit" class="btnmd btnnav" id="headform2" value=" SEND ">
</form>
The two javascript calls using chibi ajax() functions:
$("#mlist2").on('click', function(a) {
$('form').post('https://www.mydomain.com/send1.php',function(data,status){
success: $('#m-list').html("some html copy about success");
},true);
a.preventDefault();
});
$('#headform2').on('click', function(a) {
$('form').post('https://www.mydomain.com/send2.php',function(data,status){
success: $('.hdfrmmsg').html("some copy about success");
},true);
savVstr();
a.preventDefault();
});
As I look at the network traffic, submitting the #asktom form (the last one within the html code) it sends all of the inputs on the page (both forms). When submitting the mlist form, the first one to appear in the html, it sends only the inputs from the asktom form, not its own.
I have tried using the form ids
from chibi.
@mrcycling I've added a fix to 3.0.4 were some non-get ajax could be sent at JSON-P. Tested your form on my local environ with $('form').post('http://localhost:8080/ajax',function(data){console.log(data)});
and data from both forms was posted successfully.
If 3.0.4 doesn't resolve the issue for you, can you let me know your browser and version.
from chibi.
Thanks, but alas the same problem still exists. I am testing with both Chrome and Firefox (up to date versions) on Windows10.
from chibi.
@mrcycling Thanks for sharing your code. I think I've found the problem: clicking the #mlist2 button first replaces #m-list content with the gears.svg (nice, BTW) then calls Chibi post but as #m-list form data has been replaced with gears, there is no form data to submit from this area. Alternative approach would be to hide the form and show gears on submit.
from chibi.
Its a thing of beauty. Thanks for spotting my mistake. I switched it to an overlay same as is used on the asktom form and she runs great. Guess you can delete this as an issue ;-)
If you get down to SE Asia from Japan let me know and I will buy you a beer or three, chibi is a great little javascript framework.
from chibi.
@mrcycling Thanks, will do!
from chibi.
Related Issues (20)
- How to resolve the conflict with jQuery? HOT 3
- How do you select children with chibli? HOT 3
- Chibi as implied global HOT 1
- Framework vs Library HOT 1
- Event Delegation support HOT 1
- Is .data() supported similarly to jQuery? HOT 3
- Typescript definition files? HOT 1
- Idiomatic way to find out whether a checkbox is checked? HOT 4
- Please publish to npm HOT 3
- Nodes variable is shared across all invocations of $() HOT 2
- htmlAppend appends in reverse order?
- How can I change `content-type` in `POST` requests?
- General Questions
- Why you did not use Prototype Closure in building this library, which saves memory? HOT 1
- AjaxStart and AjaxComplete Callback
- $().find use a function as filter HOT 3
- Cross Domain Ajax? HOT 7
- $(document).width() in chibi? HOT 1
- this isn't this on IE8.. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chibi.