Code for the first function(keeping in mind its tested and it works fine):
$('.create-invoice').on('click',function()
{
grab_invoice_data();
// Declare a variable
var jsonObj = invoice_data;
// Lets convert our JSON object
var postData = JSON.stringify(jsonObj);
// Lets put our stringified json into a variable for posting
var postArray = {json:postData};
//if cookie exists
var i_n = $('.inv-number').val();
$.cookie('lid', ++i_n, { expires: 365 } );
//invoices created
if( $.cookie('ic') ){
var ck_inv_created = ($.cookie('ic'));
$.cookie('ic', (++ck_inv_created));
} else {
$.cookie('ic', ++inv_created);
}
})
Code for the second function(it works perfectly. this is the newly added function):
$(document).ready(function(){
$(".reloadpg").click(function(){
$.get("http://localhost/einvoice/inum.php", function(data) {
$(".on input").val(data);
});
});
});
The problem is that when i placed the second function in my code it worked but the first function stopped from working! keeping in mind they listen to the same button.. so get disparate and tried to do this code:
$('.create-invoice').on('click',function()
{
grab_invoice_data();
// Declare a variable
var jsonObj = invoice_data;
// Lets convert our JSON object
var postData = JSON.stringify(jsonObj);
// Lets put our stringified json into a variable for posting
var postArray = {json:postData};
//Below is the code i added from the second function to the first its not working here.. when it was alone outside this function it will worked but it won't here
$.download("php/json.php", postArray, 'post');
$.get( "/einvoice/inum.php", function(data) {
$('.inv-number').val(data);
});
//Above is the code i added from the second function..
//below is the rest of the code for the function which was there from the beginning, keep in mind only the below code is bing executed the above is not.. its not refreshing the part of the page it should its calling the php script successfully tho, but i will have to refresh the page my self to see the number updated
//if cookie exists
var i_n = $('.inv-number').val();
$.cookie('lid', ++i_n, { expires: 365 } );
//invoices created
if( $.cookie('ic') ){
var ck_inv_created = ($.cookie('ic'));
$.cookie('ic', (++ck_inv_created));
} else {
$.cookie('ic', ++inv_created);
}
})
i need both function to work successfully when the button is clicked not just one! any help would be appreciated
解决方案
As discussed in the comments, the problem is that you accidentally inserted a line which was not meant to be there:
$.download("php/json.php", postArray, 'post');
Just remove this line and it should all work.